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

simple try to run pnpm run test failed after following steps #240

Closed
deanhiller opened this issue May 11, 2022 · 2 comments
Closed

simple try to run pnpm run test failed after following steps #240

deanhiller opened this issue May 11, 2022 · 2 comments

Comments

@deanhiller
Copy link

very slick - this may get me using pnpm. Trying it out right now but ran into weird issue where test failure has nothing to do with the test below ->

I click use as template to my github repo to test this all out https://github.com/deanhiller/testMonorepo and I then git clone my repo and run

  • pnpm i
  • pnpm build
  • pnpm test

The last command failed with this

dean@Deans-MBP testMonorepo % pnpm run test

ts-monorepo@ test /Users/dean/workspace/personal/testMonorepo
lerna run test

lerna notice cli v4.0.0
lerna info versioning independent
lerna info Executing command in 4 packages: "pnpm run test"
lerna info run Ran npm script 'test' in '@nighttrax/ts-node' in 1.5s:

@nighttrax/ts-node@1.0.0 test /Users/dean/workspace/personal/testMonorepo/examples/ts-node
pnpm run start

@nighttrax/ts-node@1.0.0 start /Users/dean/workspace/personal/testMonorepo/examples/ts-node
ts-node -r tsconfig-paths/register src/index.ts

42
lerna info run Ran npm script 'test' in '@nighttrax/jest-babel-example' in 2.9s:

@nighttrax/jest-babel-example@1.0.0 test /Users/dean/workspace/personal/testMonorepo/examples/jest-babel
jest

lerna info run Ran npm script 'test' in '@nighttrax/cra-example' in 3.2s:

@nighttrax/cra-example@1.0.0 test /Users/dean/workspace/personal/testMonorepo/examples/cra
cross-env SKIP_PREFLIGHT_CHECK=true craco test --watchAll=false

lerna ERR! pnpm run test exited 1 in '@nighttrax/jest-example'
lerna ERR! pnpm run test stdout:

@nighttrax/jest-example@1.0.0 test /Users/dean/workspace/personal/testMonorepo/examples/jest-tsjest
jest

 ERROR  Test failed. See above for more details.
lerna ERR! pnpm run test stderr:
ts-jest[main] (WARN) Replace any occurrences of "ts-jest/utils" with just "ts-jest".
FAIL test/index.spec.ts
● Test suite failed to run

TypeError: Jest: a transform must export a `process` function.

  at ScriptTransformer._getTransformer (../../../node_modules/@jest/transform/build/ScriptTransformer.js:360:13)
  at ScriptTransformer.transformSource (../../../node_modules/@jest/transform/build/ScriptTransformer.js:427:28)
  at ScriptTransformer._transformAndBuildScript (../../../node_modules/@jest/transform/build/ScriptTransformer.js:569:40)
  at ScriptTransformer.transform (../../../node_modules/@jest/transform/build/ScriptTransformer.js:607:25)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.693 s
Ran all test suites.
lerna ERR! pnpm run test exited 1 in '@nighttrax/jest-example'
 ERROR  Test failed. See above for more details.

@deanhiller
Copy link
Author

Ok, well, after spending quite some time, it looks like it was caused by ~{versions} in package.json. I don't suppose you could fix the versions so bugs do not magically appear. I realize the idea behind ~{version} is to accept bug fixes/patches but unfortunately the easiest 'bug fixes' break other things like in this case costing others a ton of time. Java gave that same strategy a try years ago in 2010-2012 (ivy started it) and it became a nightmare as patches/bug fixes always ended up breaking other 'things' so better to lock the versions and test upgrades instead as part of a PR request instead. In this way, you can reproduce any bug in your version control system. Otherwise, you have no way to reproduce my bug as things get fixed :( .

@NiGhTTraX
Copy link
Owner

I can't reproduce this in the latest master, nor in your fork.

Dependencies are locked through pnpm-lock.yaml, so you'll always get consistent dependency trees. The ~ versions in package.json only come into play when the lock file is missing, or when installing a new dependency.

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

No branches or pull requests

2 participants