Browse Source

chore: remove internal uses of "folio" (#6931)

Replaced by "pwt" or "playwright test".
pull/6932/head
Dmitry Gozman 4 months ago
committed by GitHub
parent
commit
46a0213769
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CONTRIBUTING.md
  2. 6
      tests/playwright-test/access-data.spec.ts
  3. 8
      tests/playwright-test/base-reporter.spec.ts
  4. 20
      tests/playwright-test/basic.spec.ts
  5. 42
      tests/playwright-test/config.spec.ts
  6. 10
      tests/playwright-test/dot-reporter.spec.ts
  7. 12
      tests/playwright-test/exit-code.spec.ts
  8. 12
      tests/playwright-test/expect.spec.ts
  9. 56
      tests/playwright-test/fixture-errors.spec.ts
  10. 60
      tests/playwright-test/fixtures.spec.ts
  11. 24
      tests/playwright-test/gitignore.spec.ts
  12. 14
      tests/playwright-test/global-setup.spec.ts
  13. 30
      tests/playwright-test/golden.spec.ts
  14. 12
      tests/playwright-test/hooks.spec.ts
  15. 4
      tests/playwright-test/json-reporter.spec.ts
  16. 18
      tests/playwright-test/junit-reporter.spec.ts
  17. 4
      tests/playwright-test/line-reporter.spec.ts
  18. 2
      tests/playwright-test/list-mode.spec.ts
  19. 2
      tests/playwright-test/list-reporter.spec.ts
  20. 8
      tests/playwright-test/match-grep.spec.ts
  21. 8
      tests/playwright-test/max-failures.spec.ts
  22. 8
      tests/playwright-test/options.spec.ts
  23. 6
      tests/playwright-test/override-timeout.spec.ts
  24. 10
      tests/playwright-test/playwright-test-fixtures.ts
  25. 4
      tests/playwright-test/repeat-each.spec.ts
  26. 18
      tests/playwright-test/retry.spec.ts
  27. 4
      tests/playwright-test/shard.spec.ts
  28. 4
      tests/playwright-test/stdio.spec.ts
  29. 4
      tests/playwright-test/test-extend.spec.ts
  30. 62
      tests/playwright-test/test-ignore.spec.ts
  31. 4
      tests/playwright-test/test-info.spec.ts
  32. 10
      tests/playwright-test/test-modifiers.spec.ts
  33. 14
      tests/playwright-test/test-output-dir.spec.ts
  34. 8
      tests/playwright-test/timeout.spec.ts
  35. 10
      tests/playwright-test/types-2.spec.ts
  36. 14
      tests/playwright-test/types.spec.ts
  37. 8
      tests/playwright-test/worker-index.spec.ts

2
CONTRIBUTING.md

@ -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:

6
tests/playwright-test/access-data.spec.ts

@ -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) => {
});
`
});

8
tests/playwright-test/base-reporter.spec.ts

@ -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
tests/playwright-test/basic.spec.ts

@ -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);
});

42
tests/playwright-test/config.spec.ts

@ -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');

10
tests/playwright-test/dot-reporter.spec.ts

@ -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);
});

12
tests/playwright-test/exit-code.spec.ts

@ -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));
});

12
tests/playwright-test/expect.spec.ts

@ -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() { },
});

56
tests/playwright-test/fixture-errors.spec.ts

@ -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);

60
tests/playwright-test/fixtures.spec.ts

@ -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');

24
tests/playwright-test/gitignore.spec.ts

@ -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 });

14
tests/playwright-test/global-setup.spec.ts

@ -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 ({}) => {
});
`,

30
tests/playwright-test/golden.spec.ts

@ -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;
t