blitz-js / legacy-framework

MIT License
3 stars 2 forks source link

Tests fail out of the box on Windows #376

Closed Vandivier closed 2 years ago

Vandivier commented 2 years ago

What is the problem?

As mentioned in blitz-js/legacy-framework#377 yarn test fails out of the box on Windows at this canary SHA, which I think is equivalent to blitz 0.44. This issue adds detail for a specific test example within yarn testonly:packages

Paste all your error logs here:

$ yarn testonly:packages
yarn run v1.22.10
$ ultra -r --filter "packages/*" --concurrency 15 test
√ @blitzjs/server at packages\server 13.829s
  √ test 10.979s
    √ $ jest --passWithNoTests 6.604s
      │ No tests found, exiting with code 0
      │ 
/ @blitzjs/generator at packages\generator
  / test
    / $ jest
      │  PASS  test/utils/inflector.test.ts (9.399 s)
      │  PASS  test/prisma/field.test.ts (11.767 s)
      │
× @blitzjs/installer at packages\installer 23.983s
  × test 23.958s
    × $ jest  23.891s
      │  FAIL  test/transforms/transform-blitz-config.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/transform-blitz-config.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/update-babel-config.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/update-babel-config.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/utils/paths.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/utils/paths.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/add-prisma-generator.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/add-prisma-generator.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/add-import.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/add-import.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/add-prisma-model-attribute.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/add-prisma-model-attribute.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/set-prisma-data-source.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/set-prisma-data-source.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/produce-schema.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/produce-schema.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/add-prisma-field.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/add-prisma-field.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │ (node:3180) V8: D:\workspace\github\blitz\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:1781 Linking failure in asm.js: Unexpected stdlib member
      │ (Use `node --trace-warnings ...` to show where the warning was created)
      │  PASS  test/executors/add-dependency-executor.test.ts (13.285 s)
      │ (node:18216) V8: D:\workspace\github\blitz\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:1781 Linking failure in asm.js: Unexpected stdlib member
      │ (Use `node --trace-warnings ...` to show where the warning was created)
      │  PASS  test/executors/print-message-executor.test.tsx
      │  FAIL  test/transforms/prisma/add-prisma-model.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/add-prisma-model.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  FAIL  test/transforms/prisma/add-prisma-enum.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from 'dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       dist/blitzjs-installer.cjs.dev.js
      │       dist/blitzjs-installer.cjs.js
      │       test/transforms/prisma/add-prisma-enum.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │ (node:16796) V8: D:\workspace\github\blitz\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:1781 Linking failure in asm.js: Unexpected stdlib member
      │ (Use `node --trace-warnings ...` to show where the warning was created)
      │  PASS  test/executors/executor.test.tsx
      │
      │ Test Suites: 11 failed, 3 passed, 14 total
      │ Tests:       7 passed, 7 total
      │ Snapshots:   2 passed, 2 total
      │ Time:        17.302 s
      │ Ran all test suites.
      │
/ @blitzjs/cli at packages\cli
  / test
    / $ jest
      │  FAIL  test/commands/generate.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from '../generator/dist/blitzjs-generator.cjs.dev.js'
      │
      │     Require stack:
      │       D:/workspace/github/blitz/packages/generator/dist/blitzjs-generator.cjs.dev.js
      │       D:/workspace/github/blitz/packages/generator/dist/blitzjs-generator.cjs.js
      │       src/commands/generate.ts
      │       test/commands/generate.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var chalk = require('chalk');
      │       7 | var spawn = require('cross-spawn');
      │       8 | var fs = require('fs-extra');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (../generator/dist/blitzjs-generator.cjs.dev.js:5:15)
      │
      │  FAIL  test/commands/console.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module 'next/dist/cli/next-console' from 'test/commands/console.test.ts'
      │
      │       26 | }))
      │       27 |
      │     > 28 | jest.mock(
      │          |      ^
      │       29 |   "next/dist/cli/next-console",
      │       30 |   jest.fn(() => {
      │       31 |     return {
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (test/commands/console.test.ts:28:6)
      │
      │  FAIL  test/commands/install.test.ts
      │   ● Test suite failed to run
      │
      │     Cannot find module '@blitzjs/display' from '../installer/dist/blitzjs-installer.cjs.dev.js'
      │
      │     Require stack:
      │       D:/workspace/github/blitz/packages/installer/dist/blitzjs-installer.cjs.dev.js
      │       D:/workspace/github/blitz/packages/installer/dist/blitzjs-installer.cjs.js
      │       test/__fixtures__/installer.ts
      │       test/commands/install.test.ts
      │
      │       3 | Object.defineProperty(exports, '__esModule', { value: true });
      │       4 |
      │     > 5 | var display = require('@blitzjs/display');
      │         |               ^
      │       6 | var ink = require('ink');
      │       7 | var React = require('react');
      │       8 | var crossSpawn = require('cross-spawn');
      │
      │       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:311:11)
      │       at Object.<anonymous> (../installer/dist/blitzjs-installer.cjs.dev.js:5:15)
      │
      │  PASS  test/utils/dedent.test.ts
      │
/ blitz at packages\blitz
  / test
    / $ jest
      │  PASS  src/utils/parse-semver.test.ts (13.692 s)
      │
error 
error Command jest failed with exit code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Paste all relevant code snippets here:

n/a

What are detailed steps to reproduce this?

  1. fork repo and set blitz upstream in git. Checkout canary on fork.
  2. git fetch upstream canary && git reset --hard upstream/canary && yarn && testonly:packages

Run blitz -v and paste the output here:

$ blitz -v
Error: Cannot find module '@blitzjs/config'
Require stack:
- D:\workspace\github\blitz\packages\cli\lib\src\index.js
- C:\Users\John Vandivier\AppData\Local\Yarn\Data\global\node_modules\blitz\cli\dist\blitz-cli.cjs.dev.js
- C:\Users\John Vandivier\AppData\Local\Yarn\Data\global\node_modules\blitz\cli\dist\blitz-cli.cjs.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
    at Module._load (node:internal/modules/cjs/loader:774:27)
    at Function._load (D:\workspace\github\blitz\node_modules\@salesforce\lazy-require\lib\LazyLoader.js:99:24)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (D:\workspace\github\blitz\packages\cli\lib\src\index.js:8:18)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\workspace\\github\\blitz\\packages\\cli\\lib\\src\\index.js',
    'C:\\Users\\John Vandivier\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\blitz\\cli\\dist\\blitz-cli.cjs.dev.js',
    'C:\\Users\\John Vandivier\\AppData\\Local\\Yarn\\Data\\global\\node_modules\\blitz\\cli\\dist\\blitz-cli.cjs.js'
  ]
}

Please include below any other applicable logs and screenshots that show your problem:

Two further notes:

  1. On blitz -v: if you look in the require stack for blitz -v you can see that requires are bouncing around between local and global and the error is correct that @blitzjs/config is not installed into the local project node_modules which is expected due to the fact that it's not specified in package.json
  2. On transform-blitz-config.test.ts: This is the first failed spec within yarn testonly:packages. If you visit this file you see reference errors out of the box: image