chore: remove internal uses of "folio" (#6931)
Replaced by "pwt" or "playwright test".
This commit is contained in:
Родитель
b556ee6f5b
Коммит
46a0213769
|
@ -130,7 +130,7 @@ A barrier for introducing new installation dependencies is especially high:
|
|||
- Tests should be *hermetic*. Tests should not depend on external services.
|
||||
- Tests should work on all three platforms: Mac, Linux and Win. This is especially important for screenshot tests.
|
||||
|
||||
Playwright tests are located in [`tests`](https://github.com/microsoft/playwright/blob/master/tests) and use [Folio](https://github.com/microsoft/folio) test runner.
|
||||
Playwright tests are located in [`tests`](https://github.com/microsoft/playwright/blob/master/tests) and use `@playwright/test` test runner.
|
||||
These are integration tests, making sure public API methods and events work as expected.
|
||||
|
||||
- To run all tests:
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should access error in fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'test-error-visible-in-env.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({}, run, testInfo) => {
|
||||
await run();
|
||||
console.log('ERROR[[[' + JSON.stringify(testInfo.error, undefined, 2) + ']]]');
|
||||
|
@ -40,7 +40,7 @@ test('should access error in fixture', async ({ runInlineTest }) => {
|
|||
test('should access annotations in fixture', async ({ runInlineTest }) => {
|
||||
const { exitCode, report } = await runInlineTest({
|
||||
'test-data-visible-in-env.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({}, run, testInfo) => {
|
||||
await run();
|
||||
testInfo.annotations.push({ type: 'myname', description: 'hello' });
|
||||
|
@ -74,7 +74,7 @@ test('should report projectName in result', async ({ runInlineTest }) => {
|
|||
};
|
||||
`,
|
||||
'test-data-visible-in-env.spec.ts': `
|
||||
folio.test('some test', async ({}, testInfo) => {
|
||||
pwt.test('some test', async ({}, testInfo) => {
|
||||
});
|
||||
`
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ test('handle long test names', async ({ runInlineTest }) => {
|
|||
const title = 'title'.repeat(30);
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('${title}', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ test('handle long test names', async ({ runInlineTest }) => {
|
|||
test('print the error name', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('foobar', async ({}) => {
|
||||
const error = new Error('my-message');
|
||||
error.name = 'FooBarError';
|
||||
|
@ -49,7 +49,7 @@ test('print the error name', async ({ runInlineTest }) => {
|
|||
test('print should print the error name without a message', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('foobar', async ({}) => {
|
||||
const error = new Error();
|
||||
error.name = 'FooBarError';
|
||||
|
@ -75,7 +75,7 @@ test('print an error in a codeframe', async ({ runInlineTest }) => {
|
|||
}
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
import myLib from './my-lib';
|
||||
test('foobar', async ({}) => {
|
||||
const error = new Error('my-message');
|
||||
|
|
|
@ -20,7 +20,7 @@ import * as path from 'path';
|
|||
test('should fail', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'one-failure.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', () => {
|
||||
expect(1 + 1).toBe(7);
|
||||
});
|
||||
|
@ -35,7 +35,7 @@ test('should fail', async ({ runInlineTest }) => {
|
|||
test('should timeout', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed, failed, output } = await runInlineTest({
|
||||
'one-timeout.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('timeout', async () => {
|
||||
await new Promise(f => setTimeout(f, 10000));
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ test('should timeout', async ({ runInlineTest }) => {
|
|||
test('should succeed', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'one-success.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ test('should report suite errors', async ({ runInlineTest }) => {
|
|||
if (new Error().stack.includes('workerRunner'))
|
||||
throw new Error('Suite error');
|
||||
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('passes',() => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -81,7 +81,7 @@ test('should report suite errors', async ({ runInlineTest }) => {
|
|||
test('should respect nested skip', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed, failed, skipped } = await runInlineTest({
|
||||
'nested-skip.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.describe('skipped', () => {
|
||||
test.skip();
|
||||
test('succeeds',() => {
|
||||
|
@ -99,7 +99,7 @@ test('should respect nested skip', async ({ runInlineTest }) => {
|
|||
test('should respect excluded tests', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed } = await runInlineTest({
|
||||
'excluded.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('included test', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -135,7 +135,7 @@ test('should respect excluded tests', async ({ runInlineTest }) => {
|
|||
test('should respect focused tests', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed } = await runInlineTest({
|
||||
'focused.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('included test', () => {
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
|
@ -183,7 +183,7 @@ test('should respect focused tests', async ({ runInlineTest }) => {
|
|||
test('skip should take priority over fail', async ({ runInlineTest }) => {
|
||||
const { passed, skipped, failed } = await runInlineTest({
|
||||
'test.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.describe('failing suite', () => {
|
||||
test.fail();
|
||||
|
||||
|
@ -220,13 +220,13 @@ test('should focus test from one runTests', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a/afile.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('just a test', () => {
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
`,
|
||||
'b/bfile.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.only('focused test', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ test('should be able to define config', async ({ runInlineTest }) => {
|
|||
module.exports = { timeout: 12345 };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
expect(testInfo.timeout).toBe(12345);
|
||||
});
|
||||
|
@ -41,7 +41,7 @@ test('should prioritize project timeout', async ({ runInlineTest }) => {
|
|||
module.exports = { timeout: 500, projects: [{ timeout: 10000}, {}] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
await new Promise(f => setTimeout(f, 1500));
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ test('should prioritize command line timeout over project timeout', async ({ run
|
|||
module.exports = { projects: [{ timeout: 10000}] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
await new Promise(f => setTimeout(f, 1500));
|
||||
});
|
||||
|
@ -81,12 +81,12 @@ test('should read config from --config, resolve relative testDir', async ({ runI
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('ignored', async ({}) => {
|
||||
});
|
||||
`,
|
||||
'dir/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('run', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
@ -104,12 +104,12 @@ test('should default testDir to the config file', async ({ runInlineTest }) => {
|
|||
module.exports = {};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('ignored', async ({}) => {
|
||||
});
|
||||
`,
|
||||
'dir/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('run', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
@ -133,7 +133,7 @@ test('should be able to set reporters', async ({ runInlineTest }, testInfo) => {
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async () => {
|
||||
});
|
||||
`
|
||||
|
@ -154,12 +154,12 @@ test('should support different testDirs', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('runs once', async ({}) => {
|
||||
});
|
||||
`,
|
||||
'dir/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('runs twice', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
@ -181,7 +181,7 @@ test('should allow export default form the config file', async ({ runInlineTest
|
|||
export default { timeout: 1000 };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}, testInfo) => {
|
||||
await new Promise(f => setTimeout(f, 2000));
|
||||
});
|
||||
|
@ -203,13 +203,13 @@ test('should allow root testDir and use it for relative paths', async ({ runInli
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}, testInfo) => {
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
`,
|
||||
'dir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}, testInfo) => {
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
|
@ -226,11 +226,11 @@ test('should allow root testDir and use it for relative paths', async ({ runInli
|
|||
test('should throw when test() is called in config file', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'playwright.config.ts': `
|
||||
folio.test('hey', () => {});
|
||||
pwt.test('hey', () => {});
|
||||
module.exports = {};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
@ -247,7 +247,7 @@ test('should filter by project, case-insensitive', async ({ runInlineTest }) =>
|
|||
] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
console.log(testInfo.project.name);
|
||||
});
|
||||
|
@ -269,7 +269,7 @@ test('should print nice error when project is unknown', async ({ runInlineTest }
|
|||
] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
console.log(testInfo.project.name);
|
||||
});
|
||||
|
@ -285,7 +285,7 @@ test('should work without config file', async ({ runInlineTest }) => {
|
|||
throw new Error('This file should not be required');
|
||||
`,
|
||||
'dir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}) => {
|
||||
test.expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -308,7 +308,7 @@ test('should inerhit use options in projects', async ({ runInlineTest }) => {
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({ foo, bar }, testInfo) => {
|
||||
test.expect(foo).toBe('config');
|
||||
test.expect(bar).toBe('project');
|
||||
|
@ -328,7 +328,7 @@ test('should work with undefined values and base', async ({ runInlineTest }) =>
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}, testInfo) => {
|
||||
expect(testInfo.config.updateSnapshots).toBe('none');
|
||||
});
|
||||
|
@ -381,7 +381,7 @@ test('should work with custom reporter', async ({ runInlineTest }) => {
|
|||
};
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}) => {
|
||||
console.log('log');
|
||||
console.error('error');
|
||||
|
|
|
@ -20,7 +20,7 @@ import { test, expect, stripAscii } from './playwright-test-fixtures';
|
|||
test('render expected', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ test('render expected', async ({ runInlineTest }) => {
|
|||
test('render unexpected', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ test('render unexpected', async ({ runInlineTest }) => {
|
|||
test('render unexpected after retry', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -61,7 +61,7 @@ test('render unexpected after retry', async ({ runInlineTest }) => {
|
|||
test('render flaky', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}, testInfo) => {
|
||||
expect(testInfo.retry).toBe(3);
|
||||
});
|
||||
|
@ -81,7 +81,7 @@ test('should work from config', async ({ runInlineTest }) => {
|
|||
module.exports = { reporter: 'dot' };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ function monotonicTime(): number {
|
|||
test('should collect stdio', async ({ runInlineTest }) => {
|
||||
const { exitCode, report } = await runInlineTest({
|
||||
'stdio.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('stdio', () => {
|
||||
process.stdout.write('stdout text');
|
||||
process.stdout.write(Buffer.from('stdout buffer'));
|
||||
|
@ -61,7 +61,7 @@ test('should work with typescript', async ({ runInlineTest }) => {
|
|||
'typescript.spec.ts': `
|
||||
import './global-foo';
|
||||
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should find global foo', () => {
|
||||
expect(global['foo']).toBe(true);
|
||||
});
|
||||
|
@ -78,7 +78,7 @@ test('should work with typescript', async ({ runInlineTest }) => {
|
|||
test('should repeat each', async ({ runInlineTest }) => {
|
||||
const { exitCode, report, passed } = await runInlineTest({
|
||||
'one-success.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -94,7 +94,7 @@ test('should repeat each', async ({ runInlineTest }) => {
|
|||
test('should allow flaky', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('flake', async ({}, testInfo) => {
|
||||
expect(testInfo.retry).toBe(1);
|
||||
});
|
||||
|
@ -107,7 +107,7 @@ test('should allow flaky', async ({ runInlineTest }) => {
|
|||
test('should fail on unexpected pass', async ({ runInlineTest }) => {
|
||||
const { exitCode, failed, output } = await runInlineTest({
|
||||
'unexpected-pass.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', () => {
|
||||
test.fail();
|
||||
expect(1 + 1).toBe(2);
|
||||
|
@ -123,7 +123,7 @@ test('should respect global timeout', async ({ runInlineTest }) => {
|
|||
const now = monotonicTime();
|
||||
const { exitCode, output } = await runInlineTest({
|
||||
'one-timeout.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('timeout', async () => {
|
||||
await new Promise(f => setTimeout(f, 10000));
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should be able to extend the expect matchers with test.extend in the folio config', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
folio.expect.extend({
|
||||
pwt.expect.extend({
|
||||
toBeWithinRange(received, floor, ceiling) {
|
||||
const pass = received >= floor && received <= ceiling;
|
||||
if (pass) {
|
||||
|
@ -36,7 +36,7 @@ test('should be able to extend the expect matchers with test.extend in the folio
|
|||
}
|
||||
},
|
||||
});
|
||||
export const test = folio.test;
|
||||
export const test = pwt.test;
|
||||
`,
|
||||
'expect-test.spec.ts': `
|
||||
import { test } from './helper';
|
||||
|
@ -53,7 +53,7 @@ test('should be able to extend the expect matchers with test.extend in the folio
|
|||
test('should work with default expect prototype functions', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
const expected = [1, 2, 3, 4, 5, 6];
|
||||
test.expect([4, 1, 6, 7, 3, 5, 2, 5, 4, 6]).toEqual(
|
||||
expect.arrayContaining(expected),
|
||||
|
@ -66,7 +66,7 @@ test('should work with default expect prototype functions', async ({runTSC}) =>
|
|||
test('should work with default expect matchers', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.expect(42).toBe(42);
|
||||
`
|
||||
});
|
||||
|
@ -85,7 +85,7 @@ test('should work with jest-community/jest-extended', async ({runTSC}) => {
|
|||
}
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.expect('').toBeEmpty();
|
||||
test.expect('hello').not.toBeEmpty();
|
||||
test.expect([]).toBeEmpty();
|
||||
|
@ -109,7 +109,7 @@ test('should work with custom folio namespace', async ({runTSC}) => {
|
|||
}
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.expect.extend({
|
||||
toBeWithinRange() { },
|
||||
});
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { test, expect, stripAscii } from './playwright-test-fixtures';
|
||||
import { test, expect } from './playwright-test-fixtures';
|
||||
|
||||
test('should handle fixture timeout', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
timeout: async ({}, runTest) => {
|
||||
await runTest();
|
||||
await new Promise(f => setTimeout(f, 100000));
|
||||
|
@ -43,7 +43,7 @@ test('should handle fixture timeout', async ({ runInlineTest }) => {
|
|||
test('should handle worker fixture timeout', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
timeout: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
await new Promise(f => setTimeout(f, 100000));
|
||||
|
@ -61,7 +61,7 @@ test('should handle worker fixture timeout', async ({ runInlineTest }) => {
|
|||
test('should handle worker fixture error', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
failure: [async ({}, runTest) => {
|
||||
throw new Error('Worker failed');
|
||||
}, { scope: 'worker' }]
|
||||
|
@ -79,7 +79,7 @@ test('should handle worker fixture error', async ({ runInlineTest }) => {
|
|||
test('should handle worker tear down fixture error', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
failure: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
throw new Error('Worker failed');
|
||||
|
@ -98,7 +98,7 @@ test('should handle worker tear down fixture error', async ({ runInlineTest }) =
|
|||
test('should throw when using non-defined super worker fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({ foo }, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'worker' }]
|
||||
|
@ -108,14 +108,14 @@ test('should throw when using non-defined super worker fixture', async ({ runInl
|
|||
`
|
||||
});
|
||||
expect(result.output).toContain(`Fixture "foo" references itself, but does not have a base implementation.`);
|
||||
expect(result.output).toContain('a.spec.ts:5:31');
|
||||
expect(result.output).toContain('a.spec.ts:5:29');
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
test('should throw when defining test fixture with the same name as a worker fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'e.spec.ts': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'worker' }]
|
||||
|
@ -138,7 +138,7 @@ test('should throw when defining test fixture with the same name as a worker fix
|
|||
test('should throw when defining worker fixture with the same name as a test fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'e.spec.ts': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'test' }]
|
||||
|
@ -161,7 +161,7 @@ test('should throw when defining worker fixture with the same name as a test fix
|
|||
test('should throw when worker fixture depends on a test fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'test' }],
|
||||
|
@ -182,7 +182,7 @@ test('should throw when worker fixture depends on a test fixture', async ({ runI
|
|||
test('should throw when beforeAll hook depends on a test fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'test' }],
|
||||
|
@ -194,14 +194,14 @@ test('should throw when beforeAll hook depends on a test fixture', async ({ runI
|
|||
});
|
||||
expect(result.output).toContain('beforeAll hook cannot depend on a test fixture "foo".');
|
||||
expect(result.output).toContain(`f.spec.ts:11:12`);
|
||||
expect(result.output).toContain(`f.spec.ts:5:31`);
|
||||
expect(result.output).toContain(`f.spec.ts:5:29`);
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
test('should throw when afterAll hook depends on a test fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'test' }],
|
||||
|
@ -213,14 +213,14 @@ test('should throw when afterAll hook depends on a test fixture', async ({ runIn
|
|||
});
|
||||
expect(result.output).toContain('afterAll hook cannot depend on a test fixture "foo".');
|
||||
expect(result.output).toContain(`f.spec.ts:11:12`);
|
||||
expect(result.output).toContain(`f.spec.ts:5:31`);
|
||||
expect(result.output).toContain(`f.spec.ts:5:29`);
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
test('should define the same fixture in two files', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'worker' }]
|
||||
|
@ -229,7 +229,7 @@ test('should define the same fixture in two files', async ({ runInlineTest }) =>
|
|||
test1('works', async ({foo}) => {});
|
||||
`,
|
||||
'b.spec.ts': `
|
||||
const test2 = folio.test.extend({
|
||||
const test2 = pwt.test.extend({
|
||||
foo: [async ({}, runTest) => {
|
||||
await runTest();
|
||||
}, { scope: 'worker' }]
|
||||
|
@ -245,7 +245,7 @@ test('should define the same fixture in two files', async ({ runInlineTest }) =>
|
|||
test('should detect fixture dependency cycle', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'x.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
good1: async ({}, run) => run(),
|
||||
foo: async ({bar}, run) => run(),
|
||||
bar: async ({baz}, run) => run(),
|
||||
|
@ -262,18 +262,18 @@ test('should detect fixture dependency cycle', async ({ runInlineTest }) => {
|
|||
expect(result.output).toContain('"bar" defined at');
|
||||
expect(result.output).toContain('"baz" defined at');
|
||||
expect(result.output).toContain('"qux" defined at');
|
||||
expect(result.output).toContain('x.spec.ts:5:31');
|
||||
expect(result.output).toContain('x.spec.ts:5:29');
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
test('should not reuse fixtures from one file in another one', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({ foo: ({}, run) => run() });
|
||||
const test = pwt.test.extend({ foo: ({}, run) => run() });
|
||||
test('test1', async ({}) => {});
|
||||
`,
|
||||
'b.spec.ts': `
|
||||
const test = folio.test;
|
||||
const test = pwt.test;
|
||||
test('test1', async ({}) => {});
|
||||
test('test2', async ({foo}) => {});
|
||||
`,
|
||||
|
@ -285,7 +285,7 @@ test('should not reuse fixtures from one file in another one', async ({ runInlin
|
|||
test('should throw for cycle in two overrides', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: async ({}, run) => await run('foo'),
|
||||
bar: async ({}, run) => await run('bar'),
|
||||
});
|
||||
|
@ -309,7 +309,7 @@ test('should throw for cycle in two overrides', async ({ runInlineTest }) => {
|
|||
test('should throw when overridden worker fixture depends on a test fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: async ({}, run) => await run('foo'),
|
||||
bar: [ async ({}, run) => await run('bar'), { scope: 'worker' } ],
|
||||
});
|
||||
|
@ -327,7 +327,7 @@ test('should throw when overridden worker fixture depends on a test fixture', as
|
|||
test('should throw for unknown fixture parameter', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: async ({ bar }, run) => await run('foo'),
|
||||
});
|
||||
|
||||
|
@ -335,14 +335,14 @@ test('should throw for unknown fixture parameter', async ({ runInlineTest }) =>
|
|||
`,
|
||||
});
|
||||
expect(result.output).toContain('Fixture "foo" has unknown parameter "bar".');
|
||||
expect(result.output).toContain('f.spec.ts:5:31');
|
||||
expect(result.output).toContain('f.spec.ts:5:29');
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
test('should throw when calling runTest twice', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'f.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: async ({}, run) => {
|
||||
await run();
|
||||
await run();
|
||||
|
@ -359,7 +359,7 @@ test('should throw when calling runTest twice', async ({ runInlineTest }) => {
|
|||
test('should print nice error message for problematic fixtures', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'x.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
bad: [ undefined, { get scope() { throw new Error('oh my!') } } ],
|
||||
});
|
||||
test('works', async ({foo}) => {});
|
||||
|
@ -367,13 +367,13 @@ test('should print nice error message for problematic fixtures', async ({ runInl
|
|||
});
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.output).toContain('oh my!');
|
||||
expect(result.output).toContain('x.spec.ts:5:31');
|
||||
expect(result.output).toContain('x.spec.ts:5:29');
|
||||
});
|
||||
|
||||
test('should exit with timeout when fixture causes an exception in the test', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
throwAfterTimeout: async ({}, use) => {
|
||||
let callback;
|
||||
const promise = new Promise((f, r) => callback = r);
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should work', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
|
||||
|
@ -34,7 +34,7 @@ test('should work', async ({ runInlineTest }) => {
|
|||
test('should work with a sync test function', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
|
||||
|
@ -49,7 +49,7 @@ test('should work with a sync test function', async ({ runInlineTest }) => {
|
|||
test('should work with a sync fixture function', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: ({}, use) => {
|
||||
use(123);
|
||||
},
|
||||
|
@ -66,7 +66,7 @@ test('should work with a sync fixture function', async ({ runInlineTest }) => {
|
|||
test('should work with a non-arrow function', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
|
||||
|
@ -81,7 +81,7 @@ test('should work with a non-arrow function', async ({ runInlineTest }) => {
|
|||
test('should work with a named function', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
|
||||
|
@ -96,7 +96,7 @@ test('should work with a named function', async ({ runInlineTest }) => {
|
|||
test('should work with renamed parameters', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
|
||||
|
@ -111,7 +111,7 @@ test('should work with renamed parameters', async ({ runInlineTest }) => {
|
|||
test('should work with destructured object', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test({ foo: 'foo', bar: { x: 'x', y: 'y' }, baz: 'baz' }),
|
||||
});
|
||||
|
||||
|
@ -130,7 +130,7 @@ test('should work with destructured object', async ({ runInlineTest }) => {
|
|||
test('should work with destructured array', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(['foo', 'bar', { baz: 'baz' }]),
|
||||
more: async ({}, test) => await test(55),
|
||||
});
|
||||
|
@ -155,7 +155,7 @@ test('should work with destructured array', async ({ runInlineTest }) => {
|
|||
test('should fail if parameters are not destructured', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(123),
|
||||
});
|
||||
test('should pass', function () {
|
||||
|
@ -174,13 +174,13 @@ test('should fail if parameters are not destructured', async ({ runInlineTest })
|
|||
test('should fail with an unknown fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
folio.test('should use asdf', async ({asdf}) => {
|
||||
pwt.test('should use asdf', async ({asdf}) => {
|
||||
expect(asdf).toBe(123);
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.output).toContain('Test has unknown parameter "asdf".');
|
||||
expect(result.output).toContain('a.test.js:5:13');
|
||||
expect(result.output).toContain('a.test.js:5:11');
|
||||
expect(result.results.length).toBe(0);
|
||||
});
|
||||
|
||||
|
@ -188,7 +188,7 @@ test('should run the fixture every time', async ({ runInlineTest }) => {
|
|||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
let counter = 0;
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: async ({}, test) => await test(counter++),
|
||||
});
|
||||
test('should use asdf', async ({asdf}) => {
|
||||
|
@ -209,7 +209,7 @@ test('should only run worker fixtures once', async ({ runInlineTest }) => {
|
|||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
let counter = 0;
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
asdf: [ async ({}, test) => await test(counter++), { scope: 'worker' } ],
|
||||
});
|
||||
test('should use asdf', async ({asdf}) => {
|
||||
|
@ -229,7 +229,7 @@ test('should only run worker fixtures once', async ({ runInlineTest }) => {
|
|||
test('each file should get their own fixtures', async ({ runInlineTest }) => {
|
||||
const { results } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
worker: [ async ({}, test) => await test('worker-a'), { scope: 'worker' } ],
|
||||
test: async ({}, test) => await test('test-a'),
|
||||
});
|
||||
|
@ -239,7 +239,7 @@ test('each file should get their own fixtures', async ({ runInlineTest }) => {
|
|||
});
|
||||
`,
|
||||
'b.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
worker: [ async ({}, test) => await test('worker-b'), { scope: 'worker' } ],
|
||||
test: async ({}, test) => await test('test-b'),
|
||||
});
|
||||
|
@ -249,7 +249,7 @@ test('each file should get their own fixtures', async ({ runInlineTest }) => {
|
|||
});
|
||||
`,
|
||||
'c.test.js': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
worker: [ async ({}, test) => await test('worker-c'), { scope: 'worker' } ],
|
||||
test: async ({}, test) => await test('test-c'),
|
||||
});
|
||||
|
@ -266,7 +266,7 @@ test('tests should be able to share worker fixtures', async ({ runInlineTest })
|
|||
const { results } = await runInlineTest({
|
||||
'worker.js': `
|
||||
global.counter = 0;
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
worker: [ async ({}, test) => await test(global.counter++), { scope: 'worker' } ],
|
||||
});
|
||||
module.exports = test;
|
||||
|
@ -298,7 +298,7 @@ test('automatic fixtures should work', async ({ runInlineTest }) => {
|
|||
'a.test.js': `
|
||||
let counterTest = 0;
|
||||
let counterWorker = 0;
|
||||
const test = folio.test;
|
||||
const test = pwt.test;
|
||||
test.use({
|
||||
automaticTestFixture: [ async ({}, runTest) => {
|
||||
++counterTest;
|
||||
|
@ -344,7 +344,7 @@ test('tests does not run non-automatic worker fixtures', async ({ runInlineTest
|
|||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
let counter = 0;
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
nonAutomaticWorkerFixture: [ async ({}, runTest) => {
|
||||
++counter;
|
||||
await runTest();
|
||||
|
@ -364,7 +364,7 @@ test('should teardown fixtures after timeout', async ({ runInlineTest }, testInf
|
|||
require('fs').writeFileSync(file, '', 'utf8');
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
file: [ ${JSON.stringify(file)}, { scope: 'worker' } ],
|
||||
w: [ async ({ file }, runTest) => {
|
||||
await runTest('w');
|
||||
|
@ -391,10 +391,10 @@ test('should teardown fixtures after timeout', async ({ runInlineTest }, testInf
|
|||
test('should work with two different test objects', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: async ({}, test) => await test(123),
|
||||
});
|
||||
const test2 = folio.test.extend({
|
||||
const test2 = pwt.test.extend({
|
||||
bar: async ({}, test) => await test(456),
|
||||
});
|
||||
test1('test 1', async ({foo}) => {
|
||||
|
@ -412,7 +412,7 @@ test('should work with two different test objects', async ({ runInlineTest }) =>
|
|||
test('should work with overrides calling base', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
dep: async ({}, test) => await test('override'),
|
||||
foo: async ({}, test) => await test('base'),
|
||||
bar: async ({foo}, test) => await test(foo + '-bar'),
|
||||
|
@ -434,7 +434,7 @@ test('should work with overrides calling base', async ({ runInlineTest }) => {
|
|||
test('should understand worker fixture params in overrides calling base', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
param: [ 'param', { scope: 'worker' }],
|
||||
foo: async ({}, test) => await test('foo'),
|
||||
bar: async ({foo}, test) => await test(foo + '-bar'),
|
||||
|
@ -464,7 +464,7 @@ test('should understand worker fixture params in overrides calling base', async
|
|||
test('should work with two overrides calling base', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: async ({}, test) => await test('foo'),
|
||||
bar: async ({}, test) => await test('bar'),
|
||||
baz: async ({foo, bar}, test) => await test(foo + '-baz-' + bar),
|
||||
|
@ -484,7 +484,7 @@ test('should work with two overrides calling base', async ({ runInlineTest }) =>
|
|||
test('should not create a new worker for test fixtures', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('base test', async ({}, testInfo) => {
|
||||
expect(testInfo.workerIndex).toBe(0);
|
||||
});
|
||||
|
@ -500,7 +500,7 @@ test('should not create a new worker for test fixtures', async ({ runInlineTest
|
|||
});
|
||||
`,
|
||||
'b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
const test2 = test.extend({
|
||||
foo: async ({}, run) => {
|
||||
console.log('foo-b');
|
||||
|
@ -527,7 +527,7 @@ test('should not create a new worker for test fixtures', async ({ runInlineTest
|
|||
test('should create a new worker for worker fixtures', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('base test', async ({}, testInfo) => {
|
||||
expect(testInfo.workerIndex).toBe(1);
|
||||
});
|
||||
|
@ -543,7 +543,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest })
|
|||
});
|
||||
`,
|
||||
'b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
const test2 = test.extend({
|
||||
bar: async ({}, run) => {
|
||||
console.log('bar-b');
|
||||
|
@ -563,7 +563,7 @@ test('should create a new worker for worker fixtures', async ({ runInlineTest })
|
|||
test('should run tests in order', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test1', async ({}, testInfo) => {
|
||||
expect(testInfo.workerIndex).toBe(0);
|
||||
console.log('\\n%%test1');
|
||||
|
|
|
@ -20,11 +20,11 @@ test('should respect .gitignore', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'.gitignore': `a.spec.js`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -36,11 +36,11 @@ test('should respect nested .gitignore', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'a/.gitignore': `a.spec.js`,
|
||||
'a/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'a/b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -52,11 +52,11 @@ test('should respect enclosing .gitignore', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'.gitignore': `a/a.spec.js`,
|
||||
'a/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'a/b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -74,30 +74,30 @@ test('should respect negations and comments in .gitignore', async ({runInlineTes
|
|||
!dir1/foo/a.spec.js
|
||||
`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%a.spec.js'));
|
||||
`,
|
||||
'dir1/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%dir1/a.spec.js'));
|
||||
`,
|
||||
'dir1/foo/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%dir1/foo/a.spec.js'));
|
||||
`,
|
||||
'dir2/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%dir2/a.spec.js'));
|
||||
`,
|
||||
'dir3/.gitignore': `
|
||||
b.*.js
|
||||
`,
|
||||
'dir3/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%dir3/a.spec.js'));
|
||||
`,
|
||||
'dir3/b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => console.log('\\n%%dir3/b.spec.js'));
|
||||
`,
|
||||
}, { workers: 1 });
|
||||
|
|
|
@ -38,7 +38,7 @@ test('globalSetup and globalTeardown should work', async ({ runInlineTest }) =>
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should work', async ({}, testInfo) => {
|
||||
expect(process.env.FOO).toBe('42');
|
||||
});
|
||||
|
@ -70,7 +70,7 @@ test('globalTeardown runs after failures', async ({ runInlineTest }) => {
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should work', async ({}, testInfo) => {
|
||||
expect(process.env.FOO).toBe('43');
|
||||
});
|
||||
|
@ -101,7 +101,7 @@ test('globalTeardown does not run when globalSetup times out', async ({ runInlin
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should not run', async ({}, testInfo) => {
|
||||
});
|
||||
`,
|
||||
|
@ -128,7 +128,7 @@ test('globalSetup should be run before requiring tests', async ({ runInlineTest
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
let value = JSON.parse(process.env.FOO);
|
||||
test('should work', async ({}) => {
|
||||
expect(value).toEqual({ foo: 'bar' });
|
||||
|
@ -152,7 +152,7 @@ test('globalSetup should work with sync function', async ({ runInlineTest }) =>
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
let value = JSON.parse(process.env.FOO);
|
||||
test('should work', async ({}) => {
|
||||
expect(value).toEqual({ foo: 'bar' });
|
||||
|
@ -174,7 +174,7 @@ test('globalSetup should throw when passed non-function', async ({ runInlineTest
|
|||
module.exports = 42;
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should work', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
@ -202,7 +202,7 @@ test('globalSetup should work with default export and run the returned fn', asyn
|
|||
export default setup;
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('should work', async ({}) => {
|
||||
});
|
||||
`,
|
||||
|
|
|
@ -23,7 +23,7 @@ test('should support golden', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'a.spec.js-snapshots/snapshot.txt': `Hello world`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ Line5
|
|||
Line6
|
||||
Line7`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
const data = [];
|
||||
data.push('Line1');
|
||||
|
@ -68,7 +68,7 @@ Line7`,
|
|||
test('should write missing expectations locally', async ({runInlineTest}, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
|
@ -83,7 +83,7 @@ test('should write missing expectations locally', async ({runInlineTest}, testIn
|
|||
test('should not write missing expectations on CI', async ({runInlineTest}, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ test('should update expectations', async ({runInlineTest}, testInfo) => {
|
|||
const result = await runInlineTest({
|
||||
'a.spec.js-snapshots/snapshot.txt': `Hello world`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world updated').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
|
@ -116,7 +116,7 @@ test('should match multiple snapshots', async ({runInlineTest}) => {
|
|||
'a.spec.js-snapshots/snapshot2.txt': `Snapshot2`,
|
||||
'a.spec.js-snapshots/snapshot3.txt': `Snapshot3`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Snapshot1').toMatchSnapshot('snapshot1.txt');
|
||||
expect('Snapshot2').toMatchSnapshot('snapshot2.txt');
|
||||
|
@ -137,14 +137,14 @@ test('should match snapshots from multiple projects', async ({runInlineTest}) =>
|
|||
]};
|
||||
`,
|
||||
'p1/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Snapshot1').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
`,
|
||||
'p1/a.spec.js-snapshots/snapshot.txt': `Snapshot1`,
|
||||
'p2/a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Snapshot2').toMatchSnapshot('snapshot.txt');
|
||||
});
|
||||
|
@ -158,7 +158,7 @@ test('should use provided name', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'a.spec.js-snapshots/provided.txt': `Hello world`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot('provided.txt');
|
||||
});
|
||||
|
@ -170,7 +170,7 @@ test('should use provided name', async ({runInlineTest}) => {
|
|||
test('should throw without a name', async ({runInlineTest}) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot();
|
||||
});
|
||||
|
@ -184,7 +184,7 @@ test('should use provided name via options', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'a.spec.js-snapshots/provided.txt': `Hello world`,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect('Hello world').toMatchSnapshot({ name: 'provided.txt' });
|
||||
});
|
||||
|
@ -197,7 +197,7 @@ test('should compare binary', async ({runInlineTest}) => {
|
|||
const result = await runInlineTest({
|
||||
'a.spec.js-snapshots/snapshot.dat': Buffer.from([1,2,3,4]),
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect(Buffer.from([1,2,3,4])).toMatchSnapshot('snapshot.dat');
|
||||
});
|
||||
|
@ -211,7 +211,7 @@ test('should compare PNG images', async ({runInlineTest}) => {
|
|||
'a.spec.js-snapshots/snapshot.png':
|
||||
Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==', 'base64'),
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==', 'base64')).toMatchSnapshot('snapshot.png');
|
||||
});
|
||||
|
@ -225,7 +225,7 @@ test('should compare different PNG images', async ({runInlineTest}) => {
|
|||
'a.spec.js-snapshots/snapshot.png':
|
||||
Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==', 'base64'),
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII==', 'base64')).toMatchSnapshot('snapshot.png');
|
||||
});
|
||||
|
@ -243,7 +243,7 @@ test('should respect threshold', async ({runInlineTest}) => {
|
|||
'a.spec.js-snapshots/snapshot.png': expected,
|
||||
'a.spec.js-snapshots/snapshot2.png': expected,
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('is a test', ({}) => {
|
||||
expect(Buffer.from('${actual.toString('base64')}', 'base64')).toMatchSnapshot('snapshot.png', { threshold: 0.3 });
|
||||
expect(Buffer.from('${actual.toString('base64')}', 'base64')).not.toMatchSnapshot('snapshot.png', { threshold: 0.2 });
|
||||
|
|
|
@ -20,7 +20,7 @@ test('hooks should work with fixtures', async ({ runInlineTest }) => {
|
|||
const { results } = await runInlineTest({
|
||||
'helper.ts': `
|
||||
global.logs = [];
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
w: [ async ({}, run) => {
|
||||
global.logs.push('+w');
|
||||
await run(17);
|
||||
|
@ -79,7 +79,7 @@ test('afterEach failure should not prevent other hooks and fixtures teardown', a
|
|||
const report = await runInlineTest({
|
||||
'helper.ts': `
|
||||
global.logs = [];
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: async ({}, run) => {
|
||||
console.log('+t');
|
||||
await run();
|
||||
|
@ -111,7 +111,7 @@ test('afterEach failure should not prevent other hooks and fixtures teardown', a
|
|||
test('beforeEach failure should prevent the test, but not other hooks', async ({ runInlineTest }) => {
|
||||
const report = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.describe('suite', () => {
|
||||
test.beforeEach(async ({}) => {
|
||||
console.log('beforeEach1');
|
||||
|
@ -136,7 +136,7 @@ test('beforeEach failure should prevent the test, but not other hooks', async ({
|
|||
test('beforeAll should be run once', async ({ runInlineTest }) => {
|
||||
const report = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.describe('suite1', () => {
|
||||
let counter = 0;
|
||||
test.beforeAll(async () => {
|
||||
|
@ -159,7 +159,7 @@ test('beforeAll should be run once', async ({ runInlineTest }) => {
|
|||
test('beforeEach should be able to skip a test', async ({ runInlineTest }) => {
|
||||
const { passed, skipped, exitCode } = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.beforeEach(async ({}, testInfo) => {
|
||||
testInfo.skip(testInfo.title === 'test2');
|
||||
});
|
||||
|
@ -175,7 +175,7 @@ test('beforeEach should be able to skip a test', async ({ runInlineTest }) => {
|
|||
test('beforeAll from a helper file should throw', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'my-test.ts': `
|
||||
export const test = folio.test;
|
||||
export const test = pwt.test;
|
||||
test.beforeAll(() => {});
|
||||
`,
|
||||
'playwright.config.ts': `
|
||||
|
|
|
@ -20,7 +20,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should support spec.ok', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('math works!', async ({}) => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ test('should report projects', async ({ runInlineTest }, testInfo) => {
|
|||
};
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('math works!', async ({}) => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
|
|
@ -20,13 +20,13 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should render expected', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
`,
|
||||
'b.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('two', async ({}) => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
|
@ -47,7 +47,7 @@ test('should render expected', async ({ runInlineTest }) => {
|
|||
test('should render unexpected', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ test('should render unexpected', async ({ runInlineTest }) => {
|
|||
test('should render unexpected after retry', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -85,7 +85,7 @@ test('should render unexpected after retry', async ({ runInlineTest }) => {
|
|||
test('should render flaky', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}, testInfo) => {
|
||||
expect(testInfo.retry).toBe(3);
|
||||
});
|
||||
|
@ -99,7 +99,7 @@ test('should render stdout', async ({ runInlineTest }) => {
|
|||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
import colors from 'colors/safe';
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
console.log(colors.yellow('Hello world'));
|
||||
test.expect("abc").toBe('abcd');
|
||||
|
@ -124,7 +124,7 @@ test('should render stdout without ansi escapes', async ({ runInlineTest }) => {
|
|||
`,
|
||||
'a.test.ts': `
|
||||
import colors from 'colors/safe';
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
console.log(colors.yellow('Hello world'));
|
||||
});
|
||||
|
@ -140,7 +140,7 @@ test('should render stdout without ansi escapes', async ({ runInlineTest }) => {
|
|||
test('should render skipped', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async () => {
|
||||
console.log('Hello world');
|
||||
});
|
||||
|
@ -163,7 +163,7 @@ test('should render projects', async ({ runInlineTest }) => {
|
|||
module.exports = { projects: [ { name: 'project1' }, { name: 'project2' } ] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect, stripAscii } from './playwright-test-fixtures';
|
|||
test('render unexpected after retry', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ test('render unexpected after retry', async ({ runInlineTest }) => {
|
|||
test('render flaky', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('one', async ({}, testInfo) => {
|
||||
expect(testInfo.retry).toBe(3);
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should have relative always-posix paths', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('math works!', async ({}) => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ test('render each test with project name', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}) => {
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
|
||||
const files = {
|
||||
'match-grep/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test AA', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ const files = {
|
|||
});
|
||||
`,
|
||||
'match-grep/fdir/c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test AA', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -46,7 +46,7 @@ const files = {
|
|||
});
|
||||
`,
|
||||
'match-grep/adir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test AA', () => {
|
||||
expect(1 + 1).toBe(2);
|
||||
});
|
||||
|
@ -88,7 +88,7 @@ test('should grep by project name', async ({ runInlineTest }) => {
|
|||
]};
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
folio.test('should work', () => {});
|
||||
pwt.test('should work', () => {});
|
||||
`,
|
||||
}, { 'grep': 'foo]' });
|
||||
expect(result.passed).toBe(1);
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('max-failures should work', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
test('fail_' + i, () => {
|
||||
expect(true).toBe(false);
|
||||
|
@ -27,7 +27,7 @@ test('max-failures should work', async ({ runInlineTest }) => {
|
|||
}
|
||||
`,
|
||||
'b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
test('fail_' + i, () => {
|
||||
expect(true).toBe(false);
|
||||
|
@ -43,7 +43,7 @@ test('max-failures should work', async ({ runInlineTest }) => {
|
|||
test('-x should work', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
test('fail_' + i, () => {
|
||||
expect(true).toBe(false);
|
||||
|
@ -51,7 +51,7 @@ test('-x should work', async ({ runInlineTest }) => {
|
|||
}
|
||||
`,
|
||||
'b.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
test('fail_' + i, () => {
|
||||
expect(true).toBe(false);
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should merge options', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: 'foo',
|
||||
bar: 'bar',
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ test('should merge options', async ({ runInlineTest }) => {
|
|||
test('should run tests with different test options in the same worker', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: 'foo',
|
||||
});
|
||||
`,
|
||||
|
@ -74,7 +74,7 @@ test('should run tests with different test options in the same worker', async ({
|
|||
test('should run tests with different worker options', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: [undefined, { scope: 'worker' }],
|
||||
});
|
||||
`,
|
||||
|
@ -139,7 +139,7 @@ test('should run tests with different worker options', async ({ runInlineTest })
|
|||
test('should use options from the config', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: 'foo',
|
||||
});
|
||||
`,
|
||||
|
|
|
@ -22,7 +22,7 @@ test('should consider dynamically set value', async ({ runInlineTest }) => {
|
|||
module.exports = { timeout: 100 };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}, testInfo) => {
|
||||
expect(testInfo.timeout).toBe(100);
|
||||
})
|
||||
|
@ -41,7 +41,7 @@ test('should allow different timeouts', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}, testInfo) => {
|
||||
console.log('timeout:' + testInfo.timeout);
|
||||
});
|
||||
|
@ -59,7 +59,7 @@ test('should prioritize value set via command line', async ({ runInlineTest }) =
|
|||
module.exports = { timeout: 100 };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}, testInfo) => {
|
||||
expect(testInfo.timeout).toBe(1000);
|
||||
})
|
||||
|
|
|
@ -50,10 +50,10 @@ async function writeFiles(testInfo: TestInfo, files: Files) {
|
|||
|
||||
const internalPath = JSON.stringify(path.join(__dirname, 'entry'));
|
||||
const headerJS = `
|
||||
const folio = require(${internalPath});
|
||||
const pwt = require(${internalPath});
|
||||
`;
|
||||
const headerTS = `
|
||||
import * as folio from ${internalPath};
|
||||
import * as pwt from ${internalPath};
|
||||
`;
|
||||
|
||||
const hasConfig = Object.keys(files).some(name => name.includes('.config.'));
|
||||
|
@ -72,7 +72,7 @@ async function writeFiles(testInfo: TestInfo, files: Files) {
|
|||
const isTypeScriptSourceFile = name.endsWith('ts') && !name.endsWith('d.ts');
|
||||
const header = isTypeScriptSourceFile ? headerTS : headerJS;
|
||||
if (/(spec|test)\.(js|ts)$/.test(name)) {
|
||||
const fileHeader = header + 'const { expect } = folio;\n';
|
||||
const fileHeader = header + 'const { expect } = pwt;\n';
|
||||
await fs.promises.writeFile(fullName, fileHeader + files[name]);
|
||||
} else if (/\.(js|ts)$/.test(name) && !name.endsWith('d.ts')) {
|
||||
await fs.promises.writeFile(fullName, header + files[name]);
|
||||
|
@ -107,7 +107,7 @@ async function runTSC(baseDir: string): Promise<TSCResult> {
|
|||
};
|
||||
}
|
||||
|
||||
async function runFolio(baseDir: string, params: any, env: Env): Promise<RunResult> {
|
||||
async function runPlaywrightTest(baseDir: string, params: any, env: Env): Promise<RunResult> {
|
||||
const paramList = [];
|
||||
let additionalArgs = '';
|
||||
for (const key of Object.keys(params)) {
|
||||
|
@ -219,7 +219,7 @@ export const test = base.extend<Fixtures>({
|
|||
let runResult: RunResult | undefined;
|
||||
await use(async (files: Files, params: Params = {}, env: Env = {}) => {
|
||||
const baseDir = await writeFiles(testInfo, files);
|
||||
runResult = await runFolio(baseDir, params, env);
|
||||
runResult = await runPlaywrightTest(baseDir, params, env);
|
||||
return runResult;
|
||||
});
|
||||
if (testInfo.status !== testInfo.expectedStatus && runResult)
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should repeat from command line', async ({runInlineTest}) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test', ({}, testInfo) => {
|
||||
console.log('REPEAT ' + testInfo.repeatEachIndex);
|
||||
expect(1).toBe(1);
|
||||
|
@ -43,7 +43,7 @@ test('should repeat based on config', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('my test', ({}, testInfo) => {});
|
||||
`
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect, stripAscii } from './playwright-test-fixtures';
|
|||
test('should retry failures', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'retry-failures.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('flake', async ({}, testInfo) => {
|
||||
// Passes on the second run.
|
||||
expect(testInfo.retry).toBe(1);
|
||||
|
@ -46,7 +46,7 @@ test('should retry based on config', async ({ runInlineTest }) => {
|
|||
] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}, testInfo) => {
|
||||
// Passes on the third run.
|
||||
expect(testInfo.retry).toBe(2);
|
||||
|
@ -63,7 +63,7 @@ test('should retry based on config', async ({ runInlineTest }) => {
|
|||
test('should retry timeout', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed, failed, output } = await runInlineTest({
|
||||
'one-timeout.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('timeout', async () => {
|
||||
await new Promise(f => setTimeout(f, 10000));
|
||||
});
|
||||
|
@ -78,7 +78,7 @@ test('should retry timeout', async ({ runInlineTest }) => {
|
|||
test('should fail on unexpected pass with retries', async ({ runInlineTest }) => {
|
||||
const { exitCode, failed, output } = await runInlineTest({
|
||||
'unexpected-pass.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', () => {
|
||||
test.fail();
|
||||
expect(1 + 1).toBe(2);
|
||||
|
@ -93,7 +93,7 @@ test('should fail on unexpected pass with retries', async ({ runInlineTest }) =>
|
|||
test('should not retry unexpected pass', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed, failed, output } = await runInlineTest({
|
||||
'unexpected-pass.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', () => {
|
||||
test.fail();
|
||||
expect(1 + 1).toBe(2);
|
||||
|
@ -109,7 +109,7 @@ test('should not retry unexpected pass', async ({ runInlineTest }) => {
|
|||
test('should not retry expected failure', async ({ runInlineTest }) => {
|
||||
const { exitCode, passed, failed, output } = await runInlineTest({
|
||||
'expected-failure.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', () => {
|
||||
test.fail();
|
||||
expect(1 + 1).toBe(3);
|
||||
|
@ -129,7 +129,7 @@ test('should not retry expected failure', async ({ runInlineTest }) => {
|
|||
test('should retry unhandled rejection', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'unhandled-rejection.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('unhandled rejection', async () => {
|
||||
setTimeout(() => {
|
||||
throw new Error('Unhandled rejection in the test');
|
||||
|
@ -148,7 +148,7 @@ test('should retry unhandled rejection', async ({ runInlineTest }) => {
|
|||
test('should retry beforeAll failure', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.beforeAll(async () => {
|
||||
throw new Error('BeforeAll is bugged!');
|
||||
});
|
||||
|
@ -166,7 +166,7 @@ test('should retry beforeAll failure', async ({ runInlineTest }) => {
|
|||
test('should retry worker fixture setup failure', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
worker: [ async () => {
|
||||
throw new Error('worker setup is bugged!');
|
||||
}, { scope: 'worker' } ]
|
||||
|
|
|
@ -18,7 +18,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
|
||||
const tests = {
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test1', async () => {
|
||||
console.log('test1-done');
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ const tests = {
|
|||
});
|
||||
`,
|
||||
'b.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test4', async () => {
|
||||
console.log('test4-done');
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should get top level stdio', async ({runInlineTest}) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
console.log('\\n%% top level stdout');
|
||||
console.error('\\n%% top level stderr');
|
||||
test('is a test', () => {
|
||||
|
@ -41,7 +41,7 @@ test('should get top level stdio', async ({runInlineTest}) => {
|
|||
test('should get stdio from env afterAll', async ({runInlineTest}) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
fixture: [ async ({}, run) => {
|
||||
console.log('\\n%% worker setup');
|
||||
await run();
|
||||
|
|
|
@ -39,7 +39,7 @@ test('test.extend should work', async ({ runInlineTest }) => {
|
|||
};
|
||||
}
|
||||
|
||||
export const base = folio.test.declare();
|
||||
export const base = pwt.test.declare();
|
||||
export const test1 = base.extend(createDerivedFixtures('e1'));
|
||||
export const test2 = base.extend(createDerivedFixtures('e2'));
|
||||
`,
|
||||
|
@ -129,7 +129,7 @@ test('test.extend should work', async ({ runInlineTest }) => {
|
|||
test('test.declare should be inserted at the right place', async ({ runInlineTest }) => {
|
||||
const { output, passed } = await runInlineTest({
|
||||
'helper.ts': `
|
||||
const test1 = folio.test.extend({
|
||||
const test1 = pwt.test.extend({
|
||||
foo: async ({}, run) => {
|
||||
console.log('before-foo');
|
||||
await run('foo');
|
||||
|
|
|
@ -19,15 +19,15 @@ import * as path from 'path';
|
|||
|
||||
const tests = {
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
};
|
||||
|
@ -55,19 +55,19 @@ test('should ignore a folder', async ({ runInlineTest }) => {
|
|||
module.exports = { testIgnore: 'folder/**' };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'folder/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'folder/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'folder/c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -78,19 +78,19 @@ test('should ignore a folder', async ({ runInlineTest }) => {
|
|||
test('should ignore a node_modules', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'node_modules/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'node_modules/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'folder/c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -126,15 +126,15 @@ test('should use an array for testMatch', async ({ runInlineTest }) => {
|
|||
module.exports = { testMatch: ['b.test.ts', /\\${path.sep}a.[tes]{4}.TS$/i] };
|
||||
`,
|
||||
'dir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -150,15 +150,15 @@ test('should match absolute path', async ({ runInlineTest }) => {
|
|||
module.exports = { testDir: path.join(__dirname, 'dir'), testMatch: /dir\\${path.sep}a/ };
|
||||
`,
|
||||
'dir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'dir/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
@ -174,15 +174,15 @@ test('should match cli string argument', async ({ runInlineTest }) => {
|
|||
module.exports = { testDir: path.join(__dirname, 'dir') };
|
||||
`,
|
||||
'dir/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'dir/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
}, { args: [`dir\\${path.sep}a`] });
|
||||
|
@ -194,15 +194,15 @@ test('should match cli string argument', async ({ runInlineTest }) => {
|
|||
test('should match regex string argument', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'dir/filea.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'dir/fileb.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'filea.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
}, { args: ['/filea.*ts/'] });
|
||||
|
@ -214,19 +214,19 @@ test('should match regex string argument', async ({ runInlineTest }) => {
|
|||
test('should match by directory', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'dir-a/file.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'dir-b/file1.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'dir-b/file2.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'file.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
}, { args: ['dir-b'] });
|
||||
|
@ -241,19 +241,19 @@ test('should ignore node_modules even with custom testIgnore', async ({ runInlin
|
|||
module.exports = { testIgnore: 'a.test.ts' };
|
||||
`,
|
||||
'a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'node_modules/a.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'node_modules/b.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`,
|
||||
'folder/c.test.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('pass', ({}) => {});
|
||||
`
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should work directly', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test 1', async ({}, testInfo) => {
|
||||
expect(testInfo.title).toBe('test 1');
|
||||
});
|
||||
|
@ -34,7 +34,7 @@ test('should work directly', async ({ runInlineTest }) => {
|
|||
test('should work via fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
title: async ({}, run, testInfo) => {
|
||||
await run(testInfo.title);
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('test modifiers should work', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: true,
|
||||
});
|
||||
`,
|
||||
|
@ -133,7 +133,7 @@ test('test modifiers should work', async ({ runInlineTest }) => {
|
|||
test('test modifiers should check types', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend<{ foo: boolean }>({
|
||||
export const test = pwt.test.extend<{ foo: boolean }>({
|
||||
foo: async ({}, use, testInfo) => {
|
||||
testInfo.skip();
|
||||
testInfo.fixme(false);
|
||||
|
@ -187,7 +187,7 @@ test('test modifiers should check types', async ({runTSC}) => {
|
|||
test('should skip inside fixture', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
const test = folio.test.extend({
|
||||
const test = pwt.test.extend({
|
||||
foo: async ({}, run, testInfo) => {
|
||||
testInfo.skip(true, 'reason');
|
||||
await run();
|
||||
|
@ -206,8 +206,8 @@ test('should skip inside fixture', async ({ runInlineTest }) => {
|
|||
test('modifier with a function should throw in the test', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.ts': `
|
||||
folio.test('skipped', async ({}) => {
|
||||
folio.test.skip(() => true);
|
||||
pwt.test('skipped', async ({}) => {
|
||||
pwt.test.skip(() => true);
|
||||
});
|
||||
`,
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should work and remove non-failures on CI', async ({ runInlineTest }, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'dir/my-test.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test 1', async ({}, testInfo) => {
|
||||
if (testInfo.retry) {
|
||||
expect(testInfo.outputDir).toContain('dir-my-test-test-1-retry' + testInfo.retry);
|
||||
|
@ -63,7 +63,7 @@ test('should work and remove non-failures on CI', async ({ runInlineTest }, test
|
|||
test('should include repeat token', async ({runInlineTest}) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test', ({}, testInfo) => {
|
||||
if (testInfo.repeatEachIndex)
|
||||
expect(testInfo.outputPath('')).toContain('repeat' + testInfo.repeatEachIndex);
|
||||
|
@ -79,12 +79,12 @@ test('should include repeat token', async ({runInlineTest}) => {
|
|||
test('should include the project name', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
auto: [ async ({}, run, testInfo) => {
|
||||
await run();
|
||||
}, { auto: true } ]
|
||||
});
|
||||
export const test2 = folio.test.extend({
|
||||
export const test2 = pwt.test.extend({
|
||||
auto: [ async ({}, run, testInfo) => {
|
||||
testInfo.snapshotSuffix = 'suffix';
|
||||
await run();
|
||||
|
@ -179,7 +179,7 @@ test('should remove output dirs for projects run', async ({runInlineTest}, testI
|
|||
] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('my test', ({}, testInfo) => {});
|
||||
`
|
||||
}, { output: '' });
|
||||
|
@ -197,7 +197,7 @@ test('should remove folders with preserveOutput=never', async ({ runInlineTest }
|
|||
export default { preserveOutput: 'never' };
|
||||
`,
|
||||
'dir/my-test.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test 1', async ({}, testInfo) => {
|
||||
require('fs').writeFileSync(testInfo.outputPath('file.txt'), 'content', 'utf-8');
|
||||
if (testInfo.retry < 2)
|
||||
|
@ -216,7 +216,7 @@ test('should remove folders with preserveOutput=never', async ({ runInlineTest }
|
|||
test('should not remove folders on non-CI', async ({ runInlineTest }, testInfo) => {
|
||||
const result = await runInlineTest({
|
||||
'dir/my-test.spec.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('test 1', async ({}, testInfo) => {
|
||||
require('fs').writeFileSync(testInfo.outputPath('file.txt'), 'content', 'utf-8');
|
||||
if (testInfo.retry < 2)
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('should run fixture teardown on timeout', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'helper.ts': `
|
||||
export const test = folio.test.extend({
|
||||
export const test = pwt.test.extend({
|
||||
foo: async ({}, run, testInfo) => {
|
||||
await run();
|
||||
console.log('STATUS:' + testInfo.status);
|
||||
|
@ -41,7 +41,7 @@ test('should run fixture teardown on timeout', async ({ runInlineTest }) => {
|
|||
test('should respect test.setTimeout', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}) => {
|
||||
await new Promise(f => setTimeout(f, 1500));
|
||||
});
|
||||
|
@ -71,7 +71,7 @@ test('should respect test.setTimeout', async ({ runInlineTest }) => {
|
|||
test('should timeout when calling test.setTimeout too late', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}) => {
|
||||
await new Promise(f => setTimeout(f, 500));
|
||||
test.setTimeout(100);
|
||||
|
@ -88,7 +88,7 @@ test('should timeout when calling test.setTimeout too late', async ({ runInlineT
|
|||
test('should respect test.slow', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('fails', async ({}) => {
|
||||
await new Promise(f => setTimeout(f, 1500));
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('basics should work', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.describe('suite', () => {
|
||||
test.beforeEach(async () => {});
|
||||
test('my test', async({}, testInfo) => {
|
||||
|
@ -35,7 +35,7 @@ test('basics should work', async ({runTSC}) => {
|
|||
test('can pass sync functions everywhere', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const test = folio.test.extend<{ foo: string }>({
|
||||
const test = pwt.test.extend<{ foo: string }>({
|
||||
foo: ({}, use) => use('bar'),
|
||||
});
|
||||
test.beforeEach(({ foo }) => {});
|
||||
|
@ -51,7 +51,7 @@ test('can pass sync functions everywhere', async ({runTSC}) => {
|
|||
test('can return anything from hooks', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test.beforeEach(() => '123');
|
||||
test.afterEach(() => 123);
|
||||
test.beforeAll(() => [123]);
|
||||
|
@ -64,7 +64,7 @@ test('can return anything from hooks', async ({runTSC}) => {
|
|||
test('test.declare should check types', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'helper.ts': `
|
||||
export const test = folio.test;
|
||||
export const test = pwt.test;
|
||||
export const test1 = test.declare<{ foo: string }>();
|
||||
export const test2 = test1.extend<{ bar: number }>({
|
||||
bar: async ({ foo }, run) => { await run(parseInt(foo)); }
|
||||
|
@ -76,7 +76,7 @@ test('test.declare should check types', async ({runTSC}) => {
|
|||
`,
|
||||
'playwright.config.ts': `
|
||||
import { test1 } from './helper';
|
||||
const configs: folio.Config[] = [];
|
||||
const configs: pwt.Config[] = [];
|
||||
configs.push({});
|
||||
configs.push({
|
||||
define: {
|
||||
|
|
|
@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
|
|||
test('sanity', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
// @ts-expect-error
|
||||
test.foo();
|
||||
`
|
||||
|
@ -31,7 +31,7 @@ test('should check types of fixtures', async ({runTSC}) => {
|
|||
const result = await runTSC({
|
||||
'helper.ts': `
|
||||
export type MyOptions = { foo: string, bar: number };
|
||||
export const test = folio.test.extend<{ foo: string }, { bar: number }>({
|
||||
export const test = pwt.test.extend<{ foo: string }, { bar: number }>({
|
||||
foo: 'foo',
|
||||
bar: [ 42, { scope: 'worker' } ],
|
||||
});
|
||||
|
@ -74,14 +74,14 @@ test('should check types of fixtures', async ({runTSC}) => {
|
|||
`,
|
||||
'playwright.config.ts': `
|
||||
import { MyOptions } from './helper';
|
||||
const configs1: folio.Config[] = [];
|
||||
const configs1: pwt.Config[] = [];
|
||||
configs1.push({ use: { foo: '42', bar: 42 } });
|
||||
configs1.push({ use: { foo: '42', bar: 42 }, timeout: 100 });
|
||||
|
||||
const configs2: folio.Config<MyOptions>[] = [];
|
||||
const configs2: pwt.Config<MyOptions>[] = [];
|
||||
configs2.push({ use: { foo: '42', bar: 42 } });
|
||||
// @ts-expect-error
|
||||
folio.runTests({ use: { foo: '42', bar: 42 } }, {});
|
||||
pwt.runTests({ use: { foo: '42', bar: 42 } }, {});
|
||||
// @ts-expect-error
|
||||
configs2.push({ use: { bar: '42' } });
|
||||
// @ts-expect-error
|
||||
|
@ -149,14 +149,14 @@ test('should check types of fixtures', async ({runTSC}) => {
|
|||
test('config should allow void/empty options', async ({runTSC}) => {
|
||||
const result = await runTSC({
|
||||
'playwright.config.ts': `
|
||||
const configs: folio.Config[] = [];
|
||||
const configs: pwt.Config[] = [];
|
||||
configs.push({});
|
||||
configs.push({ timeout: 100 });
|
||||
configs.push();
|
||||
configs.push({ use: { foo: 42 }});
|
||||
`,
|
||||
'a.spec.ts': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('my test', async () => {
|
||||
});
|
||||
`
|
||||
|
|
|
@ -21,7 +21,7 @@ test('should run in parallel', async ({ runInlineTest }) => {
|
|||
'1.spec.ts': `
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', async ({}, testInfo) => {
|
||||
expect(testInfo.workerIndex).toBe(0);
|
||||
// First test waits for the second to start to work around the race.
|
||||
|
@ -35,7 +35,7 @@ test('should run in parallel', async ({ runInlineTest }) => {
|
|||
'2.spec.ts': `
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', async ({}, testInfo) => {
|
||||
// First test waits for the second to start to work around the race.
|
||||
fs.mkdirSync(testInfo.project.outputDir, { recursive: true });
|
||||
|
@ -51,7 +51,7 @@ test('should run in parallel', async ({ runInlineTest }) => {
|
|||
test('should reuse worker for multiple tests', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', async ({}, testInfo) => {
|
||||
expect(testInfo.workerIndex).toBe(0);
|
||||
});
|
||||
|
@ -75,7 +75,7 @@ test('should not reuse worker for different suites', async ({ runInlineTest }) =
|
|||
module.exports = { projects: [{}, {}, {}] };
|
||||
`,
|
||||
'a.test.js': `
|
||||
const { test } = folio;
|
||||
const { test } = pwt;
|
||||
test('succeeds', async ({}, testInfo) => {
|
||||
console.log('workerIndex-' + testInfo.workerIndex);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче