sodatea / vite-jest

First-class Vite integration for Jest
MIT License
401 stars 51 forks source link

Running examples/vue-app-ts tests throws "Preset vite-jest is invalid" #19

Open imomaliev opened 2 years ago

imomaliev commented 2 years ago

Runnig vite-jest in example vue-app-ts throws an error.

Steps to reproduce

  1. git clone git@github.com:sodatea/vite-jest.git
  2. cd examples/vue-app-ts
  3. Update package.json
    -    "vite-jest": "workspace:*",
    +    "vite-jest": "^0.0.3",
  4. npm i
  5. npm run test:unit

    $ npm run test:unit
    
    > test:unit
    > vite-jest
    
    ● Validation Error:
    
      Preset vite-jest is invalid:
    
      String.prototype.startsWith called on null or undefined
      TypeError: String.prototype.startsWith called on null or undefined
        at startsWith (<anonymous>)
        at node:internal/errors:811:19
        at Array.filter (<anonymous>)
        at node:internal/errors:809:16
        at prepareStackTrace (node:internal/errors:96:12)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:38)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:94:18)
    
      Configuration Documentation:
      https://jestjs.io/docs/configuration
    
    /path/to/project/vite-jest/examples/vue-app-ts/node_modules/execa/lib/error.js:60
                    error = new Error(message);
                            ^
    
    Error: Command failed with exit code 1: node --experimental-vm-modules /path/to/project/vite-jest/examples/vue-app-ts/node_modules/jest/bin/jest.js
        at makeError (/path/to/project/vite-jest/examples/vue-app-ts/node_modules/execa/lib/error.js:60:11)
        at Function.module.exports.sync (/path/to/project/vite-jest/examples/vue-app-ts/node_modules/execa/index.js:194:17)
        at file:///path/to/project/vite-jest/examples/vue-app-ts/node_modules/vite-jest/bin/vite-jest.js:11:7
        at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
        at async Loader.import (node:internal/modules/esm/loader:178:24)
        at async Object.loadESM (node:internal/process/esm_loader:68:5)
        at async handleMainPromise (node:internal/modules/run_main:63:12) {
      shortMessage: 'Command failed with exit code 1: node --experimental-vm-modules /path/to/project/vite-jest/examples/vue-app-ts/node_modules/jest/bin/jest.js',
      command: 'node --experimental-vm-modules /path/to/project/vite-jest/examples/vue-app-ts/node_modules/jest/bin/jest.js',
      escapedCommand: 'node --experimental-vm-modules "/path/to/project/vite-jest/examples/vue-app-ts/node_modules/jest/bin/jest.js"',
      exitCode: 1,
      signal: undefined,
      signalDescription: undefined,
      stdout: undefined,
      stderr: undefined,
      failed: true,
      timedOut: false,
      isCanceled: false,
      killed: false
    }

Environment info

MacOS Big Sur 11.5.1

$ npm --version
7.19.1
$ node --version
v16.6.0
LaurenceM10 commented 2 years ago

Same issue here!

cedmax commented 1 year ago

it seems to be working with Jest v27 (I haven't tried the example, but I had the same problem in another repo and I solved it downgrading jest)