Skip to content

Commit 85cf463

Browse files
committed
refactor(plugin-axe): inline script paths in tests
1 parent f0793e7 commit 85cf463

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed
Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import ansis from 'ansis';
12
import path from 'node:path';
23
import { fileURLToPath } from 'node:url';
34
import type { Page } from 'playwright-core';
4-
import { describe, expect, it, vi } from 'vitest';
55
import { loadSetupScript, runSetup } from './setup.js';
66

77
describe('loadSetupScript integration', () => {
@@ -15,44 +15,39 @@ describe('loadSetupScript integration', () => {
1515
);
1616

1717
it('should load a valid setup script with default export', async () => {
18-
const scriptPath = path.join(fixturesDir, 'valid-setup.ts');
19-
20-
const setupFn = await loadSetupScript(scriptPath);
18+
const setupFn = await loadSetupScript(
19+
path.join(fixturesDir, 'valid-setup.ts'),
20+
);
2121

2222
expect(typeof setupFn).toBe('function');
2323
});
2424

2525
it('should execute loaded setup script with runSetup', async () => {
26-
const scriptPath = path.join(fixturesDir, 'valid-setup.ts');
2726
const mockPage = { goto: vi.fn() } as unknown as Page;
2827

29-
const setupFn = await loadSetupScript(scriptPath);
28+
const setupFn = await loadSetupScript(
29+
path.join(fixturesDir, 'valid-setup.ts'),
30+
);
3031
await runSetup(setupFn, mockPage);
3132

3233
expect(mockPage.goto).toHaveBeenCalledWith('about:blank');
3334
});
3435

3536
it('should throw error for setup script without default export', async () => {
36-
const scriptPath = path.join(fixturesDir, 'invalid-setup-no-default.ts');
37-
38-
await expect(loadSetupScript(scriptPath)).rejects.toThrow(
39-
/Invalid.*SetupScriptModule/,
40-
);
37+
await expect(
38+
loadSetupScript(path.join(fixturesDir, 'invalid-setup-no-default.ts')),
39+
).rejects.toThrow(`Invalid ${ansis.bold('SetupScriptModule')}`);
4140
});
4241

4342
it('should throw error for setup script with non-function default export', async () => {
44-
const scriptPath = path.join(fixturesDir, 'invalid-setup-wrong-type.ts');
45-
46-
await expect(loadSetupScript(scriptPath)).rejects.toThrow(
47-
/Invalid.*SetupScriptModule/,
48-
);
43+
await expect(
44+
loadSetupScript(path.join(fixturesDir, 'invalid-setup-wrong-type.ts')),
45+
).rejects.toThrow(`Invalid ${ansis.bold('SetupScriptModule')}`);
4946
});
5047

5148
it('should throw error for non-existent setup script', async () => {
52-
const scriptPath = path.join(fixturesDir, 'non-existent.ts');
53-
54-
await expect(loadSetupScript(scriptPath)).rejects.toThrow(
55-
/Setup script not found/,
56-
);
49+
await expect(
50+
loadSetupScript(path.join(fixturesDir, 'non-existent.ts')),
51+
).rejects.toThrow('Setup script not found');
5752
});
5853
});

0 commit comments

Comments
 (0)