Commit Graph

53 Commits

Author SHA1 Message Date
Dmitry Gozman e62a54af7a
fix(test runner): do not revert the transform (#31930)
This allows a dynamic import of a TS file to be processed by Babel.

For some reason, Playwright used to revert the CJS transforms. However,
ESM loader and transforms are always active, so CJS should be too.
2024-07-31 13:17:09 -07:00
Dmitry Gozman b9106a4c42
fix(test runner): do not use `@babel/plugin-transform-dynamic-import` (#31285)
Historically, this plugin was important to translate dynamic imports
into require calls so that we can intercept them and transpile.

This is not needed anymore with ESM loader enabled by default, so we can
avoid this transformation and support dynamic imports of ESM-only
packages/files.

Fixes #17075, fixes #23255, fixes #31140, references #23662.
2024-06-13 06:18:44 -07:00
Pavel Feldman 4bafe71eb1
chore: unconflict ct test ports (#29332) 2024-02-05 16:47:39 -08:00
Pavel Feldman 92ad1b385c
chore: refactor import processing in ct (#28975) 2024-01-12 20:02:27 -08:00
Pavel Feldman f4f9e526a2
chore: tolerate css imports (#26626)
Fixes https://github.com/microsoft/playwright/issues/24580
2023-08-23 08:32:23 -07:00
Kristo Jorgenson d5d155df1f
fix(typescript): allow directory imports (#23254)
This updates previous work in #22887 to align more fully with
`--moduleResolution=bundler`, allowing index files to be imported with
the /index extension

---------

Signed-off-by: Kristo Jorgenson <kristojorg@users.noreply.github.com>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
2023-06-05 08:58:25 -07:00
Pavel Feldman ee3864913a
chore: allow stub JSX instances in type module (#23211)
Fixes https://github.com/microsoft/playwright/issues/23207
2023-05-22 15:34:50 -07:00
Pavel Feldman 2fc6341841
chore: remove node version checks from esm tests (#23031) 2023-05-16 11:07:34 -07:00
Dmitry Gozman 44a934c160
feat(test runner): support `.cjs` and `.cts` files (#22971)
Fixes #22579.
2023-05-11 15:41:50 -07:00
Dmitry Gozman cd49f5c466
feat(typescript): align with `--moduleResolution=bundler` (#22887)
This relaxes import requirements and allows importing `.ts` files
without an extension in CJS and ESM modes.

Fixes #22169.
2023-05-09 16:26:29 -07:00
Pavel Feldman 9c25a04267
chore: use custom JSX runtime to stub-out erroneous JSX usage (#22827)
Fixes https://github.com/microsoft/playwright/issues/22789
2023-05-04 11:44:59 -07:00
Dmitry Gozman bf661535a6
fix(testMatch): do not count `test.ts` and `spec.ts` as test files by default (#22440) 2023-04-17 12:57:33 -07:00
Dmitry Gozman 47e5c02a21
fix(test runner): update default testMatch (#22006)
The intent of default test match is allowing `example.spec.ts` and
`example.test.ts` files. However, it was also matching `test.example.ts`
that should not be considered a test by default.

Fixes #21979.
2023-03-27 14:28:44 -07:00
Dmitry Gozman 58a23bc7a0
fix(test runner): allow worker-only dynamic imports (#21545)
Fixes #21409.
2023-03-10 08:58:26 -08:00
Dmitry Gozman 6769a311ed
feat(test runner): error out when one test file imports another (#21357)
This situation is not supported, and we can now detect it by looking at
collected file dependencies.

Fixes #21270.
2023-03-02 15:09:50 -08:00
Nowell Strite 000583e048
fix(loader): experimentalLoader with node@18 (#21106)
There is currently a bug when running `node@18.14.2` when running with
experimentalLoader

```
TypeError: The URL must be of scheme file
  at new NodeError (node:internal/errors:399:5)
  at Object.fileURLToPath (node:internal/url:1492:11)
  at resolve (./node_modules/@playwright/test/lib/experimentalLoader.js:39:48)
  at nextResolve (node:internal/modules/esm/loader:163:22)
  at ESMLoader.resolve (node:internal/modules/esm/loader:838:24)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:21)
```

This came from my test `vrt.spec.ts` which had a non package import
inside of it

```ts
import fs from "node:fs/promises"
```

The test run failed due to node imports not returning fileUrls when
resolved.

---------

Co-authored-by: Nowell Strite <nstrite@nvidia.com>
2023-02-22 14:28:03 -08:00
Pavel Feldman 06fc72b6ed
revert(#12706): also fix related bugs it introduced (#21070) 2023-02-21 14:15:11 -08:00
Dmitry Gozman 91da67fab1
test: remove magic headers in ttest (#20867)
Instead, explicitly import from '@playwright/test'.
2023-02-14 19:20:56 -08:00
Pavel Feldman 1b941bcf2e
chore: simplify ttests (#20733) 2023-02-07 15:11:44 -08:00
Dmitry Gozman b971dd3417
fix(test runner): show deep strack traces during imports (#20305)
Fixes #20239.
2023-01-24 08:49:06 -08:00
Pavel Feldman 9f31bcfbab
chore: refactor graceful close, rename to host/main (#20283) 2023-01-22 15:04:29 -08:00
Pavel Feldman 736cf5c585
fix(tsx): resolve .js imports to .tsx as well (#20092)
Fixes: https://github.com/microsoft/playwright/issues/20039
2023-01-13 10:49:10 -08:00
Grant Colestock a30aac5668
fix: make sure jsx fragments are transformed (#19755)
Fixes: #19142
2022-12-31 11:08:36 -08:00
Han Yeong-woo 00ffd74727
fix(runner): import export assignment from ts (#19559) 2022-12-19 14:41:29 -08:00
Pavel Feldman fb9555fb5d
fix(ts): resolve .js to .ts in non-ESM mode too (#18219)
Fixes https://github.com/microsoft/playwright/issues/18077
2022-10-20 12:21:22 -07:00
Dmitry Gozman 9fe72a1da8
fix(test runner): remove unused type imports during transform (#18157)
Fixes #18117.
2022-10-19 13:06:11 -07:00
Pavel Feldman 7ab4c17519
chore: support jsx/tsx syntax in test files (#18123)
Fixes https://github.com/microsoft/playwright/issues/17964
2022-10-18 12:45:33 -07:00
Dmitry Gozman da7feb9cc6
fix(esm): silence warning when running with experimental loader (#17493)
Unfortunately, this silences all warnings, not just the experimental
loader warning.
2022-09-21 10:56:17 -07:00
Dmitry Gozman 48ac918cec
test: unflake "should load web server w/o esm loader in ems module" (#17269) 2022-09-12 11:42:04 -07:00
Pavel Feldman 4d892475da
chore: do not use experimental loader for web server (#16733) 2022-08-23 10:22:05 -07:00
Pavel Feldman d7be1fcca8
fix(esm): allow importing ts from esm (#16735) 2022-08-23 10:20:56 -07:00
Pavel Feldman d02914fa3a
chore: relax transpilation criteria to allow ems imports of .vue files (#15592) 2022-07-13 16:11:38 -07:00
Dmitry Gozman b86926e691
fix(test runner): update timeout error messages (#15117)
Some of the current timeout error messages are confusing, because they do not suggest that the issue is most likely a slow test. This PR updates timeout messages as follows:
- Test timeout of 30000ms exceeded.
- Test timeout of 30000ms exceeded while setting up "browser".
- Test timeout of 30000ms exceeded while tearing down "context".
- Test timeout of 30000ms exceeded while setting up "playwright configuration".
- Test timeout of 30000ms exceeded while running "beforeEach" hook.
- Test timeout of 30000ms exceeded while running "afterEach" hook.
- "beforeAll" hook timeout of 30000ms exceeded.
- "afterAll" hook timeout of 30000ms exceeded.
- Worker teardown timeout of 30000ms exceeded.
- "skip" modifier timeout of 30000ms exceeded.
- Fixture "myCustomFixture" timeout of 5000ms exceeded.
2022-06-30 17:05:08 -07:00
Pavel Feldman 88664c39c9
chore: remove esm error interception, it only confuses users (#14829) 2022-06-13 12:32:42 -07:00
Pavel Feldman c4b003a29a
chore: don't mask ESM error (#14628) 2022-06-03 15:28:53 -07:00
Dmitry Gozman 9420a53939
fix(esm): make sure import from './foo.js' is supported (#13137)
Drive-by: migrate all @esm tests to esm.spec.ts.
2022-03-28 14:37:46 -07:00
Pavel Feldman 4aaa63beaa
test: add a test for #12837 (#12838) 2022-03-18 18:09:59 -07:00
Pavel Feldman 4d3d0e2bda
chore: enable ts-esm support by default (#12658) 2022-03-10 14:48:33 -08:00
Max Schmitt 3f468abedd
fix(test-runner): ESM compatibly on Windows (#12615) 2022-03-10 19:27:25 +01:00
Dmitry Gozman e895bc2751
reland(test-runner): rely on test title paths instead of ordinal (#12611)
Fixes #11904

Co-authored-by: Andrey Lushnikov <lushnikov@chromium.org>
2022-03-08 19:06:25 -08:00
Pavel Feldman 6a663ef54f
chore(test-runner): revert recent changes to fix tests (#12439)
* Revert "fix(hooks): separate test timeout from beforeAll/afterAll timeouts (#12413)"

This reverts commit 73dee69558.

* Revert "fix(test-runner): rely on test title paths instead of ordinal (#12414)"

This reverts commit d744a87aee.

* Revert "chore(test runner): run hooks/modifiers as a part of the test  (#12329)"

This reverts commit 47045ba48d.
2022-03-01 09:11:17 -08:00
Andrey Lushnikov d744a87aee
fix(test-runner): rely on test title paths instead of ordinal (#12414)
Fixes #11904
2022-02-28 15:40:23 -08:00
pierscowburn 5db7ce5964
fix: propagate exit code in experimental mode (#12070)
In experimental ESM mode a child process is forked in order to run the tests. Currently the exit code of this child process is not propagated to the exit code of the parent process, which means that the process exits with a status code of `0` even if some of the tests failed.

This makes it difficult to use Playwright in CI in experimental mode, as the CI pipeline as a whole will pass despite the test failures.

This change addresses this by propagating the exit code in the case where it is non-zero.
2022-02-15 13:10:35 -08:00
Andrey Lushnikov ef21ce3f56
feat(test-runner): filter out syntax error stack traces (#12095)
Filter out long stack traces from babel when it fails compilation
due to syntax error in test.
2022-02-14 14:33:14 -08:00
Andrey Lushnikov b0daa7754f
feat: filter stack traces to exclude test runner frames (#11795)
Before:

```bash
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at Proxy.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/expect.ts:151:30)
        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
        at /Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:335:13
        at runNextTicks (node:internal/process/task_queues:61:5)
        at processImmediate (node:internal/timers:437:9)
        at TestInfoImpl._runFn (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:164:7)
        at WorkerRunner._runTestWithBeforeHooks (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:317:24)
        at TimeoutRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-core/src/utils/async.ts:48:14)
        at TestInfoImpl._runWithTimeout (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:151:7)
        at WorkerRunner._runTestOrAllHook (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:276:5)
        at WorkerRunner._runSuite (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:190:11)
        at WorkerRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:137:9)
        at process.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/worker.ts:87:5)
```

after:

```
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
```
2022-02-01 18:40:44 -08:00
Pavel Feldman 5d19f16601
feat(esm): introduce experimental PW_EXPERIMENTAL_TS_ESM option (#10519) 2021-11-24 14:17:01 -08:00
Pavel Feldman 7eb3f76f49
feat(esm): allow running tests in type module projects (#10503) 2021-11-24 12:42:48 -08:00
Joel Einbinder 0cad0de3e3
fix(test runner): better error message when importing typescript from esmodule (#10061) 2021-11-08 16:25:40 -05:00
Max Schmitt cd22072685
chore: enable object-curly-spacing in ESLint (#9168) 2021-09-27 18:58:08 +02:00
Joel Einbinder eb31b9e4a9
feat(test-runner): support esm modules in more places (#7542) 2021-07-12 11:59:58 -05:00