Skip to content
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

fix js tests on local #32

Merged
merged 1 commit into from
Sep 10, 2024
Merged

fix js tests on local #32

merged 1 commit into from
Sep 10, 2024

Conversation

ashfame
Copy link
Member

@ashfame ashfame commented Sep 10, 2024

On my local, in trunk branch, I couldn't run tests (despite clearing node_modules dir and with a fresh npm install), was getting this error:

npm run test

> test
> jest --config=jest.config.js

ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/ashfame/git/try-wordpress/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/ashfame/git/try-wordpress/jest.config.js:1:1
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async requireOrImportModule (/Users/ashfame/git/try-wordpress/node_modules/jest-util/build/requireOrImportModule.js:55:32)
    at async readConfigFileAndSetRootDir (/Users/ashfame/git/try-wordpress/node_modules/jest-config/build/readConfigFileAndSetRootDir.js:112:22)
    at async readInitialOptions (/Users/ashfame/git/try-wordpress/node_modules/jest-config/build/index.js:392:15)
    at async readConfig (/Users/ashfame/git/try-wordpress/node_modules/jest-config/build/index.js:147:48)
    at async readConfigs (/Users/ashfame/git/try-wordpress/node_modules/jest-config/build/index.js:424:26)
    at async runCLI (/Users/ashfame/git/try-wordpress/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/Users/ashfame/git/try-wordpress/node_modules/jest-cli/build/run.js:130:37)

With the change in this PR, it worked again. Not sure how it's working in Github actions. 🤔

@ashfame ashfame requested a review from psrpinto September 10, 2024 12:33
@ashfame ashfame self-assigned this Sep 10, 2024
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The file was renamed when I changed the type to module in package.json, but I forgot to edit it here.

With the change in this PR, it worked again. Not sure how it's working in Github actions. 🤔

Currently the tests aren't running on CI yet. I guess we should do that eventually but currently there are no actual tests. The test setup came for the patterns-everywhere repo, but we haven't been writing tests yet.

@ashfame
Copy link
Member Author

ashfame commented Sep 10, 2024

Gotcha! I was just following the readme and ran into it :)

@ashfame ashfame merged commit 40d3909 into trunk Sep 10, 2024
1 check passed
@ashfame ashfame deleted the local_js_tests_fix branch September 10, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants