fix: isolate CHRNX seed lifecycle tests
This commit is contained in:
10 files changed
+277
-316
No files matched your search
@@ -34,11 +34,30 @@ test( 'database scenarios run only in a serial Chromium project after all read-o
|
||||
assert.match( scenario, /test\.afterAll[\s\S]*seedScenario\(\s*['"]default['"]\s*\)/ );
|
||||
} );
|
||||
|
||||
test( 'the npm integration chain finishes PHP and seed-state checks before browser workers', async () => {
|
||||
test( 'the npm integration chain finishes isolated PHP before browser workers', async () => {
|
||||
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
|
||||
assert.match( manifest.scripts[ 'test:integration' ], /tests\/integration\/seed-state\.sh/ );
|
||||
assert.match(
|
||||
manifest.scripts.test,
|
||||
/npm run test:php && npm run test:integration && npm run test:e2e/,
|
||||
);
|
||||
assert.equal( manifest.scripts[ 'test:integration' ], undefined );
|
||||
assert.match( manifest.scripts.test, /npm run test:php && npm run test:e2e/ );
|
||||
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /seed-state\.sh/ );
|
||||
} );
|
||||
|
||||
test( 'restore lifecycle runs only in isolated PHPUnit and never in shared DB scripts', async () => {
|
||||
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
|
||||
const phpTest = await readFile( 'tests/php/FixtureEnvironmentTest.php', 'utf8' );
|
||||
const library = await readFile( 'scripts/lib/fixture-environment.php', 'utf8' );
|
||||
const files = await readdir( 'tests/integration' ).catch( () => [] );
|
||||
|
||||
assert.deepEqual( files.filter( ( name ) => /seed-state|harness-preservation/.test( name ) ), [] );
|
||||
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /tests\/integration|seed-state/ );
|
||||
assert.match( phpTest, /WP_UnitTestCase/ );
|
||||
assert.match( phpTest, /chrnx_fixture_environment_snapshot/ );
|
||||
assert.match( phpTest, /chrnx_fixture_environment_restore/ );
|
||||
assert.match( library, /raw_base64/ );
|
||||
} );
|
||||
|
||||
test( 'PHPUnit is pinned to the isolated tests-cli database', async () => {
|
||||
const manifest = JSON.parse( await readFile( 'package.json', 'utf8' ) );
|
||||
assert.match( manifest.scripts[ 'test:php' ], /wp-env run tests-cli/ );
|
||||
assert.doesNotMatch( manifest.scripts[ 'test:php' ], /wp-env run cli/ );
|
||||
assert.doesNotMatch( JSON.stringify( manifest.scripts ), /wp-env run cli[^\n"]*phpunit/ );
|
||||
} );
|
||||
@@ -12,7 +12,7 @@ test('Composer provides the PHPUnit Polyfills version required by WordPress test
|
||||
assert.equal(composer['require-dev']['phpunit/phpunit'], '^9.6');
|
||||
assert.equal(
|
||||
packageConfig.scripts['test:php'],
|
||||
'wp-env run cli --env-cwd=wp-content/themes/chrnx -- composer exec phpunit --',
|
||||
'wp-env run tests-cli --env-cwd=wp-content/themes/chrnx -- composer exec phpunit --',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user