Nuxt.js: Attempting to integrate Jest with Nuxt.js

Created on 12 Jul 2017  ·  14Comments  ·  Source: nuxt/nuxt.js

Hi @Atinux and @eddyerburgh,

This is the first attempt to integrate Jest with Nuxt.js . I ran into couple of error related to nuxt library which I don't understand. It would be nice to have a look at the sample codebase here https://github.com/piyushchauhan2011/nuxt-with-jest .

Pros:

  • Was able to test store and sample .js files
  • I was also able to unit-test components
  • Snapshot testing

screen shot 2017-07-12 at 7 34 08 pm

Broken:

  • End to end testing
    ERROR in ./.nuxt/client.js
    Module build failed: Error: Cannot find module '../../package' from 'node.js'
        at Resolver.resolveModule (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-resolve/build/index.js:179:17)
        at Resolver._getVirtualMockPath (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-resolve/build/index.js:296:23)
        at Resolver._getAbsolutPath (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-resolve/build/index.js:279:10)
        at Resolver.getModuleID (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-resolve/build/index.js:252:31)
        at Runtime._shouldMock (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-runtime/build/index.js:574:37)
        at Runtime.requireModuleOrMock (/Users/piyushchauhan/Documents/jirnexu/nuxt-with-jest/node_modules/jest-runtime/build/index.js:402:14)

This feature request is available on Nuxt.js community (#c936)
enhancement

Most helpful comment

Hey guys, I created a zero-configuration test runner for Nuxt.js using Jest and Puppeteer: https://github.com/studbits/nuxt-jest-puppeteer

Hopefully it helps!

All 14 comments

Hi @piyushchauhan2011

Great job :)
We will work on it after 1.0 release, it's really nice to see someone taking the lead on this!

CC @pi0

Currently, we use a mix of jest and ava for unit and end-to-end testing 😄 which obviously isn't a good solution but working for now, as we needed something quick for CircleCI to output some level of coverage. It would be nice to have jest integration natively or through nuxt modules @Atinux @pi0

As compared to ava I also like the integration of jest with vscode, very helpful during development

screen shot 2017-07-13 at 11 43 56 am

Updated the repo with latest rc3. Love to see the dynamic components working now 💯 . Hopefully we will get testing going after 1.0 release. :excited:

@piyushchauhan2011 So excited too 👍 I'll open a new issue on repo for some updates.

Any updates on this issue? Was anybody able to get the E2E testing working with Jest and the new Nuxt Builder/ webpack issues?

I got a way to test Nuxt applications e2e using Testcafe, after writing a module to support Nuxt. Maybe you find it useful. You can check the package.json and the test directory to get a clue how to get it working.
testcafe-nuxt-selectors: https://github.com/kartojal/testcafe-nuxt-selectors
testcafe library: https://devexpress.github.io/testcafe/

@kartojal any conclusions after testing with testcafe and nuxt? any problems, obstacles, pros, cons?

The only obstacle i found, after creating a module for supportig nuxt, was
learning another test framework, with a small learning curve. But is
working really good, helps me to test the nuxt app end 2 end, in a variety
of browsers and in a visual way (if needed, the tests can run headless too).
2017-10-03 12:30 GMT+02:00 Lukas Borawski notifications@github.com:

@kartojal https://github.com/kartojal any conclusions after testing
with testcafe and nuxt? any problems, obstacles, pros, cons?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nuxt/nuxt.js/issues/1075#issuecomment-333802428, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AKqXR5s7SEgA4-GgsIDu-8ByeYKOAAwLks5sogy6gaJpZM4OVfw9
.

Hey guys, I created a zero-configuration test runner for Nuxt.js using Jest and Puppeteer: https://github.com/studbits/nuxt-jest-puppeteer

Hopefully it helps!

@alidcastano this looks really cools. Will be great to get it polished, and get more people using it in order to get all the best practices in. I suggest to add a sample project using this to nuxt examples here.

@pi0 @Atinux @alexchopin now when 1.0 is finally out would be great to come with some recommended test harness setup and examples, using jest and maybe other popular testing frameworks

cc @clarkdo I think this issue can be closed :relaxed:

This feature-request has been cancelled by @Atinux.

Implemented by @alidcastano on https://github.com/alidcastano/nuxt-jest-puppeteer

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pehbehbeh picture pehbehbeh  ·  3Comments

maicong picture maicong  ·  3Comments

vadimsg picture vadimsg  ·  3Comments

VincentLoy picture VincentLoy  ·  3Comments

uptownhr picture uptownhr  ·  3Comments