question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

next {dev,build} command should ignore __tests__ dir

See original GitHub issue

In jest example, if we move ./__tests__ to ./pages/__tests__ and then run next build then an error occurs.

The solution is not trying to solve this error, but make next ignore some patterns, fe *.{spec,test}.js or some dirs like __{mocks,tests}__

Otherwise, those dev files would be available in public dir, WDYT ?

Issues #988 #1545 #1689 talks about the same problem (sadly without any solution).

BTW next.js rocks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
scspercommented, Sep 6, 2017

agreed with @sboudrias-aa and @ericnograles . @arunoda please reconsider this decision. writing tests next to the module also helps a lot with refactoring because you can delete / move entire directories and still have things work.

11reactions
bensalilijamescommented, May 9, 2017

Design suggestion: add an excludeFile option to next.config.js which accepts a function to exclude certain files from being webpack’d.

This option would be passed straight to emit-file-loader’s exclude option (and merged with the normal node_modules exclude) to prevent it from building it as a page. For example:

// next.config.js
module.exports = {
  excludeFile: (str) => /\*.{spec,test}.js/.test(str)
}

If that sounds good I can make a PR for this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to exclude test files in next.js during build? - Stack Overflow
You can have your .spec files in any other folder such as /components but not /pages . As per documentation, for testing pages...
Read more >
Testing | Next.js
Learn how to set up Next.js with three commonly used testing tools — Cypress, Playwright, Jest, and React Testing Library.
Read more >
How To Set Up Next.JS With Jest, React Testing Library and ...
One last thing to add is that we want to ignore Playwright's tests when we're running our npm run test command. To do...
Read more >
Get started with Netlify CLI
Then, run this command from any directory in your terminal: ... With continuous deployment, Netlify will automatically deploy new versions of your site...
Read more >
IBM Cloud CLI Developer Tools ( ibmcloud dev ) commands
The test , debug , and run commands expect to find a compiled app so you must run a build ... Usage: ibmcloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found