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

[Bug]: default esm preset fails because of mts extension #3837

Closed
Maxim-Mazurok opened this issue Sep 26, 2022 · 1 comment · Fixed by #3833
Closed

[Bug]: default esm preset fails because of mts extension #3837

Maxim-Mazurok opened this issue Sep 26, 2022 · 1 comment · Fixed by #3833
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@Maxim-Mazurok
Copy link

Version

29.0.2

Steps to reproduce

  1. clone ts-jest-issue-repro-1 branch: git clone -b ts-jest-issue-repro-1 https://github.com/Maxim-Mazurok/google-api-typings-generator/tree/ts-jest-issue-repro-1
  2. cd google-api-typings-generator
  3. optional nvm i
  4. npm ci
  5. npm run jest test/config.spec.ts
  6. Observe the error: ReferenceError: exports is not defined

Expected behavior

Uncomment

// defaultsESMPatched.extensionsToTreatAsEsm =
//   defaultsESMPatched.extensionsToTreatAsEsm?.filter(x => x !== '.mts');

in jest.config.ts and re-run npm run jest test/config.spec.ts - see no error.

Actual behavior

Error:

maxim@64QHKR3:~/google-api-typings-generator$ npm run jest test/config.spec.ts

> jest
> node --experimental-vm-modules node_modules/jest/bin/jest.js "test/config.spec.ts"

 FAIL  test/config.spec.ts
  ● Test suite failed to run

    ReferenceError: exports is not defined

      1 | import {supportedApis} from '../bin/auto-publish/config.js';
    > 2 | import {excludedRestDescriptionIds} from '../src/app.js';
        |                       ^
      3 |
      4 | describe('Config validation', () => {
      5 |   it('Excluded and supported APIs should not overlap', () => {

      at test/config.spec.ts:2:23

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.964 s
Ran all test suites matching /test\/config.spec.ts/i.
(node:30622) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Debug log

https://gist.github.com/Maxim-Mazurok/d9b00b7493c49c40ea2594c72434d621

Additional context

mts was added here: #3713

Environment

System:
    OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
  Binaries:
    Node: 18.2.0 - ~/.nvm/versions/node/v18.2.0/bin/node
    npm: 8.9.0 - ~/.nvm/versions/node/v18.2.0/bin/npm
  npmPackages:
    jest: ^29.0.3 => 29.0.3
@Maxim-Mazurok Maxim-Mazurok changed the title [Bug]: [Bug]: default esm preset fails with mts files Sep 26, 2022
@Maxim-Mazurok Maxim-Mazurok changed the title [Bug]: default esm preset fails with mts files [Bug]: default esm preset fails because of mts extension Sep 26, 2022
@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 27, 2022

Fixed in #3833 and will be included in the next patch release

@ahnpnl ahnpnl closed this as completed Sep 27, 2022
@ahnpnl ahnpnl linked a pull request Sep 27, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants