blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

blitz jest preset doesn't work in plain javascript projects #299

Closed beerose closed 2 years ago

beerose commented 2 years ago

What is the problem?

After creating a new javascript project with blitz new test --js, and running yarn test, it results in a validation error:

● Validation Error:
Module blitz should have "jest-preset.js" or "jest-preset.json" file at the root.

The jest-preset.js, requires a tsconfig.json (https://github.com/blitz-js/blitz/blob/canary/packages/blitz/jest-preset.js#L5), which is then used to ensure any path aliases in tsconfig also work in jest (https://github.com/blitz-js/blitz/blob/canary/packages/blitz/jest-preset.js#L25). Apart from that, there are two references to "<rootDir>/test/setup.ts" while in JavaScript projects it should be a "<rootDir>/test/setup.js"

Paste all your error logs here:

> yarn jest

yarn run v1.19.2
$ /Users/aleksandra/workspace/test/node_modules/.bin/jest
● Validation Error:

  Module blitz should have "jest-preset.js" or "jest-preset.json" file at the root.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

Paste all relevant code snippets here:

n/a

What are detailed steps to reproduce this?

  1. blitz new test --js,
  2. yarn test.

Run blitz -v and paste the output here:

macOS Big Sur | darwin-x64 | Node: v14.17.6

blitz: 0.40.0-canary.8 (global)
blitz: 0.40.0-canary.9 (local)

  Package manager: yarn 
  System:
    OS: macOS 11.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 305.01 MB / 16.00 GB
    Shell: 5.0.11 - /usr/local/bin/bash
  Binaries:
    Node: 14.17.6 - /usr/local/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: 3.1.1 => 3.1.1 
    blitz: 0.40.0-canary.9 => 0.40.0-canary.9 
    prisma: 3.1.1 => 3.1.1 
    react: alpha => 18.0.0-alpha-d174d063d-20210922 
    react-dom: alpha => 18.0.0-alpha-d174d063d-20210922 
    typescript: Not Found