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

test: add jest example/test #224

Merged
merged 10 commits into from
Nov 6, 2023
Merged

test: add jest example/test #224

merged 10 commits into from
Nov 6, 2023

Conversation

danielroe
Copy link
Member

resolves #347

@barelyhuman
Copy link
Contributor

Screenshot 2023-11-06 at 11 55 33 PM

Was this an issue that was already solved?

@danielroe
Copy link
Member Author

You may need to build first with pnpm prepack.

@barelyhuman
Copy link
Contributor

Screenshot 2023-11-07 at 12 24 36 AM

Works with a .cjs file of jest, will see if I can get it working with .ts config as well

@barelyhuman
Copy link
Contributor

barelyhuman commented Nov 6, 2023

Opened: #225

There's syntax styling changes also in the example tests, do we want to add a eslint config in the same PR?

@danielroe
Copy link
Member Author

I think there's already an eslint config 🤔

@barelyhuman
Copy link
Contributor

I think there's already an eslint config 🤔

top level, yes.

It's not inheriting it all the way in, ends up using my defaults

@danielroe
Copy link
Member Author

Ah, I think that's okay. We want the examples to be separately cloneable, and we run the autofix from the top.

@barelyhuman
Copy link
Contributor

Ah, I think that's okay. We want the examples to be separately cloneable, and we run the autofix from the top.

Oh okay 👌

@userquin
Copy link
Member

userquin commented Nov 6, 2023

I have Jest configured, but Nuxt auto import failing...

imagen

@barelyhuman
Copy link
Contributor

Yeah, I ended up adding an import for it manually.

jest and its sandbox doesn't like a lot of things

@userquin
Copy link
Member

userquin commented Nov 6, 2023

Yeah, I ended up adding an import for it manually.

jest and its sandbox doesn't like a lot of things

userquin@a4aebc5

@userquin
Copy link
Member

userquin commented Nov 6, 2023

Now Windows fs error:

imagen

@barelyhuman
Copy link
Contributor

That's from my commits? I didn't test on windows but let me know if you have a hard time

@userquin
Copy link
Member

userquin commented Nov 6, 2023

That's from my commits? I didn't test on windows but let me know if you have a hard time

No, just testing on my local, but both seem almost identical, I'll check with your changes.

@userquin
Copy link
Member

userquin commented Nov 6, 2023

can you test in your local adding .npmrc (root folder) with shell-emulator=true and changing the script to "test": "NODE_OPTIONS=--experimental-vm-modules jest"?

EDIT: We should also change test utils deps in tests to use workspace:* protocol.

The error on my local Windows laptop:

test/server.e2e.spec.ts 
  ● setup

    TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'file:\\\D:\work\issues-repos\test-utils-pr-
224\node_modules\.pnpm\nuxt@3.8.1_@types+node@20.8.10_eslint@8.53.0_rollup@3.29.4_typescript@5.2.2_vite@4.5.0\node_modules\nuxt\dist'

      91 |     });
      92 |   }
    > 93 |   ctx.nuxt = await kit.loadNuxt({
         |              ^
      94 |     cwd: ctx.options.rootDir,
      95 |     dev: ctx.options.dev,
      96 |     overrides: ctx.options.nuxtConfig,

      at Function.createRequire (../../node_modules/.pnpm/jest-runtime@29.7.0/node_modules/jest-runtime/build/index.js:1618:23)
      at module.exports (../../node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:639)
      at createJITI (../../node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/dist/jiti.js:1:250383)
      at Object.<anonymous>.module.exports (../../node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/lib/index.js:14:10)
      at setup (../../node_modules/.pnpm/nuxt@3.8.1_@types+node@20.8.10_eslint@8.53.0_rollup@3.29.4_typescript@5.2.2_vite@4.5.0/node_modules/nuxt/dist/index.mjs:3052:28)
      at normalizedModule (../../node_modules/.pnpm/@nuxt+kit@3.8.1_rollup@3.29.4/node_modules/@nuxt/kit/dist/index.mjs:2141:37)
      at installModule (../../node_modules/.pnpm/@nuxt+kit@3.8.1_rollup@3.29.4/node_modules/@nuxt/kit/dist/index.mjs:2439:95)
      at initNuxt (../../node_modules/.pnpm/nuxt@3.8.1_@types+node@20.8.10_eslint@8.53.0_rollup@3.29.4_typescript@5.2.2_vite@4.5.0/node_modules/nuxt/dist/index.mjs:3696:7)
      at loadNuxt (../../node_modules/.pnpm/nuxt@3.8.1_@types+node@20.8.10_eslint@8.53.0_rollup@3.29.4_typescript@5.2.2_vite@4.5.0/node_modules/nuxt/dist/index.mjs:3783:5)
      at Module.loadNuxt (../../node_modules/.pnpm/@nuxt+kit@3.8.1_rollup@3.29.4/node_modules/@nuxt/kit/dist/index.mjs:2584:19)
      at loadFixture (../../dist/index.mjs:93:14)
      at Object.setup2 (../../dist/index.mjs:154:7)

@userquin
Copy link
Member

userquin commented Nov 6, 2023

same error with latest changes here reverting "@nuxt/test-utils": "workspace:*" to use "@nuxt/test-utils": "latest" on my local

@danielroe danielroe marked this pull request as ready for review November 6, 2023 21:46
@danielroe danielroe merged commit 8634ae6 into main Nov 6, 2023
3 checks passed
@danielroe danielroe deleted the test/jest branch November 6, 2023 22:20
@danielroe danielroe mentioned this pull request Dec 2, 2023
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

Successfully merging this pull request may close these issues.

Using @nuxt/test-utils with jest results in Returning a Promise from "describe" is not supported
3 participants