diff --git a/package.json b/package.json index cf9ed1c..3e14d2a 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "composer": "wp-env run cli --env-cwd=wp-content/themes/chrnx composer", "phpcs": "npm run composer -- exec phpcs -- -q", "test:smoke": "node --test tests/smoke/*.test.mjs", - "test:js": "wp-scripts test-unit-js --runInBand", + "test:js": "wp-scripts test-unit-js --runInBand --modulePathIgnorePatterns='/.worktrees/'", "test:php": "wp-env run tests-cli --env-cwd=wp-content/themes/chrnx -- composer exec phpunit --", "test:e2e": "playwright test", "lint:js": "wp-scripts lint-js assets/js tests/js tests/e2e", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index bf799cc..ffe91fc 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,6 +4,7 @@ . + */.worktrees/* */node_modules/* */vendor/* diff --git a/tests/smoke/project-config.test.mjs b/tests/smoke/project-config.test.mjs index b737e0c..ae6235e 100644 --- a/tests/smoke/project-config.test.mjs +++ b/tests/smoke/project-config.test.mjs @@ -31,6 +31,16 @@ test('scripts activate chrnx and run Composer from the mapped theme', async () = ); }); +test('Jest discovers JavaScript tests only from the active checkout', async () => { + const pkg = JSON.parse(await readFile('package.json', 'utf8')); + + assert.match( + pkg.scripts['test:js'], + /--modulePathIgnorePatterns='\/\.worktrees\/'/, + ); + assert.equal(pkg.jest, undefined); +}); + test('PHP quality tools enforce the CHRNX conventions and cannot pass an empty suite', async () => { const phpcs = await readFile('phpcs.xml.dist', 'utf8'); const phpunit = await readFile('phpunit.xml.dist', 'utf8'); @@ -39,6 +49,7 @@ test('PHP quality tools enforce the CHRNX conventions and cannot pass an empty s assert.match(phpcs, //); assert.match(phpcs, /name="text_domain"[^>]+value="chrnx"/); assert.match(phpcs, /name="prefixes"[^>]+value="chrnx_"/); + assert.match(phpcs, /\*\/\.worktrees\/\*<\/exclude-pattern>/); assert.match(phpunit, /bootstrap="tests\/php\/bootstrap\.php"/); assert.match(phpunit, /failOnEmptyTestSuite="true"/); assert.match(phpunit, /tests\/php<\/directory>/);