# Integration Tests This directory contains the integration test suite for the Gutenberg project. These tests live in the internal `@wordpress/integration-tests` workspace package, which is private and not published. ## What Are Integration Tests? Unlike unit tests that test individual functions in isolation, these tests exercise multiple packages working together. They cover: | Test file | What it tests | |---|---| | `blocks-schema.test.js` | Validates all `block.json` files in the repo against the JSON schema | | `theme-schema.test.js` | Validates all `theme.json` files in the repo against the JSON schema | | `wp-env-schema.test.js` | Validates `.wp-env.json` against the JSON schema | | `blocks-raw-handling.jsdom.test.js` | Tests raw paste/HTML handling across the full block pipeline | | `full-content/full-content.jsdom.test.js` | Tests full block serialization round-trips using fixtures | | `is-valid-block.jsdom.test.js` | Tests block validation with editor hooks applied | | `shortcode-converter.jsdom.test.js` | Tests shortcode-to-block conversion | | `non-matched-tags-handling.jsdom.test.js` | Tests handling of unrecognized HTML tags during paste | ## Running the Tests Integration tests run as part of the standard unit test command: ```bash npm run test:unit ``` To run only the integration tests: ```bash npm run test:unit -- test/integration ``` To run a specific integration test file: ```bash npm run test:unit -- test/integration/blocks-schema.test.js ``` ## Fixtures ### Block fixtures The `fixtures/blocks/` directory contains serialized block fixtures used by `full-content.jsdom.test.js` to verify that blocks serialize and parse correctly. To generate missing fixtures: ```bash npm run fixtures:generate ``` To regenerate all fixtures from scratch: ```bash npm run fixtures:regenerate ``` ### theme.json schema fixtures `theme-schema.test.js` decides what to expect from where a file sits, so adding a case means adding a file and nothing else. | Location | Expectation | |---|---| | any `theme.json` under `lib/`, `phpunit/`, `test/`, or `packages/*/src/` | must validate, and must set `$schema` | | any `.json` file directly in `fixtures/schemas/` | must fail validation | Name an invalid fixture after the schema definition that rejects it, adding a `_suffix` when one definition needs several cases, as in `stylesPropertiesAndElementsComplete_pseudo.json`. Nothing enforces the name, so check the failure comes from the definition you meant to test. ## Vitest configuration These tests use [the shared Vitest configuration](/test/unit/vitest.config.mjs), which discovers tests from the repository root. The [filename-based environment conventions](/docs/contributors/code/testing-overview.md#folder-structure) select Node, jsdom, or Browser Mode. Run a focused set with `npm run test:unit -- test/integration/`.