New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to import ESM-only modules in a test #6853
Comments
You are right. TestCafe transpiles |
Any update on this issue? this is happening with @percy/testcafe package as well. |
No updates yet. Once we get any results, we will post them in this thread. |
Any updates on this issue? |
Created bug reproduction project: |
Thank you for the example. We do not have news on this. We will update this thread once we have any progress. |
I've recently witnessed the same. Although I think this was working for me before... |
I also have this issue |
We are experiencing this issue as well. I have just upgraded our Angular project from 12 to 13 and we are using the Angular Material Harness functionality in our e2e tests, so we would directly use the Material library in ESM format, which is not possible now. I understand fixing this issue might take a considerable amount of time, therefore I would like to know if the issue is currently being investigated/developed or not, so I can make a decision on how to go forward.. |
@bvklingeren, |
<!-- Thank you for your contribution. Before making a PR, please read our contributing guidelines at https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution We recommend creating a *draft* PR, so that you can mark it as 'ready for review' when you are done. --> ## Purpose Add the possibility to run tests in ESM mode ## Approach - [X] Research ways to implement running ESM files consistently - [X] Research ways to compile test files on the run - [X] Add loader hooks for ESM - [X] Run tests with dynamic import - [x] Fix tests - [X] Add handling error `ERR_REQUIRE_ESM` - [X] Add workflow for running tests in ESM - [x] Add additional tests ## References Closes #6853 PR in `bin-v8-flags-filter` DevExpress/bin-v8-flags-filter#1 PR in `callsite-record` inikulin/callsite-record#28 Temp `bin-v8-flags-filter` assembling [bin-v8-flags-filter-1.2.0.zip](https://github.com/DevExpress/testcafe/files/10175237/bin-v8-flags-filter-1.2.0.zip) Temp `callsite-record` assembling [callsite-record-4.1.3.zip](https://github.com/DevExpress/testcafe/files/10175241/callsite-record-4.1.3.zip) ## Pre-Merge TODO - [x] Write tests for your proposed changes - [x] Make sure that existing tests do not fail
What is your Scenario?
Importing ESM-only modules in a test throws ERR_REQUIRE_ESM error.
What is the Current behavior?
An error is thrown:
What is the Expected behavior?
Test executes correctly.
What is your public website URL? (or attach your complete example)
Please see the isolated test code below.
What is your TestCafe test code?
Your complete configuration file
No specific configuration file.
Your complete test report
Please refer to the error message above.
Screenshots
Not applicable.
Steps to Reproduce
Please install node-fetch 3.2.0 and run the attached test code.
TestCafe version
1.18.3
Node.js version
14.17.1
Command-line arguments
testcafe chrome test.js
Browser name(s) and version(s)
chrome
Platform(s) and version(s)
Windows 11
Other
The test code runs with node-fetch 2.6.7, which supports
require()
. It seems that import statements are transpiled to require calls, which fails for all ESM-only modules.The text was updated successfully, but these errors were encountered: