mirror of
https://github.com/codex-team/editor.js
synced 2026-03-16 15:45:47 +01:00
test: make sure that E2E tests always run with the latest changes
This commit is contained in:
parent
ff118c4ce8
commit
fb2329811f
1 changed files with 34 additions and 0 deletions
34
test/playwright/tests/helpers/ensure-build.ts
Normal file
34
test/playwright/tests/helpers/ensure-build.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
let didBuild = false;
|
||||
|
||||
/**
|
||||
* Ensure the Editor.js bundle is freshly built before running Playwright tests.
|
||||
*
|
||||
* Necessary because the Playwright fixtures load the UMD bundle directly from the dist folder.
|
||||
* Without rebuilding we might exercise stale code that doesn't match the current TypeScript sources.
|
||||
*/
|
||||
export const ensureEditorBundleBuilt = (): void => {
|
||||
if (didBuild) {
|
||||
return;
|
||||
}
|
||||
|
||||
const projectRoot = path.resolve(__dirname, '../../../..');
|
||||
const result = spawnSync('yarn', [ 'build:test' ], {
|
||||
cwd: projectRoot,
|
||||
stdio: 'inherit',
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`Building Editor.js for Playwright failed with exit code ${result.status ?? 'unknown'}.`);
|
||||
}
|
||||
|
||||
didBuild = true;
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue