mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 05:46:34 +00:00
[PUI] Add coverage testing (#6881)
* add coverage to PUI * fix testing command * always do all steps * fix test assumptions * add test for serving and logging into pui from django / cui tech stack * fix up coverage * fix intentation * remove paralell flags * remove coverage finish step * remove flag * change names * add full clickdown test * more tests * more tests * sprinkle in some timeouts * try using admin * disable page 1 tests for now * remove additional tests for now * only build sourcemaps if coverage is enabled * fix sourcemap assumption * Update .github/workflows/qc_checks.yaml Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com> * fix package.json * add finish step --------- Co-authored-by: Lukas <76838159+wolflu05@users.noreply.github.com>
This commit is contained in:
47
src/frontend/tests/baseFixtures.ts
Normal file
47
src/frontend/tests/baseFixtures.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { test as baseTest } from '@playwright/test';
|
||||
import * as crypto from 'crypto';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const istanbulCLIOutput = path.join(process.cwd(), '.nyc_output');
|
||||
export const classicUrl = 'http://127.0.0.1:8000';
|
||||
|
||||
export function generateUUID(): string {
|
||||
return crypto.randomBytes(16).toString('hex');
|
||||
}
|
||||
|
||||
export const test = baseTest.extend({
|
||||
context: async ({ context }, use) => {
|
||||
await context.addInitScript(() =>
|
||||
window.addEventListener('beforeunload', () =>
|
||||
(window as any).collectIstanbulCoverage(
|
||||
JSON.stringify((window as any).__coverage__)
|
||||
)
|
||||
)
|
||||
);
|
||||
await fs.promises.mkdir(istanbulCLIOutput, { recursive: true });
|
||||
await context.exposeFunction(
|
||||
'collectIstanbulCoverage',
|
||||
(coverageJSON: string) => {
|
||||
if (coverageJSON)
|
||||
fs.writeFileSync(
|
||||
path.join(
|
||||
istanbulCLIOutput,
|
||||
`playwright_coverage_${generateUUID()}.json`
|
||||
),
|
||||
coverageJSON
|
||||
);
|
||||
}
|
||||
);
|
||||
await use(context);
|
||||
for (const page of context.pages()) {
|
||||
await page.evaluate(() =>
|
||||
(window as any).collectIstanbulCoverage(
|
||||
JSON.stringify((window as any).__coverage__)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const expect = test.expect;
|
Reference in New Issue
Block a user