fix(runner): friendly error message instead of "digests do not match" (#15939)
This commit is contained in:
parent
ac480240bb
commit
c0d78c5642
|
|
@ -300,8 +300,14 @@ export class FixtureRunner {
|
||||||
setPool(pool: FixturePool) {
|
setPool(pool: FixturePool) {
|
||||||
if (!this.testScopeClean)
|
if (!this.testScopeClean)
|
||||||
throw new Error('Did not teardown test scope');
|
throw new Error('Did not teardown test scope');
|
||||||
if (this.pool && pool.digest !== this.pool.digest)
|
if (this.pool && pool.digest !== this.pool.digest) {
|
||||||
throw new Error('Digests do not match');
|
throw new Error([
|
||||||
|
`Playwright detected inconsistent test.use() options.`,
|
||||||
|
`Most common mistakes that lead to this issue:`,
|
||||||
|
` - Calling test.use() outside of the test file, for example in a common helper.`,
|
||||||
|
` - One test file imports from another test file.`,
|
||||||
|
].join('\n'));
|
||||||
|
}
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -584,3 +584,39 @@ test('should not run user fn when require fixture has failed', async ({ runInlin
|
||||||
'%%foo',
|
'%%foo',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should provide helpful error message when digests do not match', async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'helper.ts': `
|
||||||
|
export const test = pwt.test.extend({
|
||||||
|
foo: [ async ({}, use) => use(), { scope: 'worker' } ],
|
||||||
|
});
|
||||||
|
|
||||||
|
test.use({ foo: 'foo' });
|
||||||
|
`,
|
||||||
|
'a.spec.ts': `
|
||||||
|
import { test } from './helper';
|
||||||
|
|
||||||
|
test('test-a', ({ foo }) => {
|
||||||
|
expect(foo).toBe('foo');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
'b.spec.ts': `
|
||||||
|
import { test } from './helper';
|
||||||
|
|
||||||
|
test('test-b', ({ foo }) => {
|
||||||
|
expect(foo).toBe('foo');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
'c.spec.ts': `
|
||||||
|
import { test } from './helper';
|
||||||
|
|
||||||
|
test('test-c', ({ foo }) => {
|
||||||
|
expect(foo).toBe('foo');
|
||||||
|
});
|
||||||
|
`,
|
||||||
|
}, { workers: 1 });
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
expect(stripAnsi(result.output)).toContain('Playwright detected inconsistent test.use() options.');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue