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

Compilation succeeds but test finish immediately #278

Open
jglover opened this issue Jun 28, 2018 · 9 comments
Open

Compilation succeeds but test finish immediately #278

jglover opened this issue Jun 28, 2018 · 9 comments

Comments

@jglover
Copy link

jglover commented Jun 28, 2018

Hi,
I'm running mocha-webpack in order to utilise path aliasing in Webpack/Typescript TSC and I'm running into an issue where Webpack compilation succeeds but Mocha returns immediately with:
0 Passing. Tests completed successfully
I was previously using the following command to run mocha over the compiled js, which ran without problem.
node_modules/.bin/mocha --require source-map-support/register mocha-setup.js 'compiled/**/*-spec.js'
I've now changed mocha out for mocha-webpack as follows
node_modules/.bin/mocha-webpack --webpack-config webpack.config.js --require source-map-support/register mocha-setup.js 'compiled/**/*-spec.js'

packages are "webpack": "4.12.1" and "mocha-webpack": "2.0.0-beta.0"
I'm unsure what I'm missing, much appreciate any help!

screen shot 2018-06-28 at 10 15 47 am

@4lph4-Ph4un
Copy link

I have exactly the same issue!

@jglover
Copy link
Author

jglover commented Jul 3, 2018

@4lph4-Ph4un I believe TSC is emitting compiled files with aliases that mocha-webpack cannot interpret. I may have been mistaken in my assumption that mocha-webpack had a loader for them.

@strootje
Copy link

@jglover I had the same error. But I fixed this by using the --recursive tag for mocha-webpack directly. I (wrongly) assumed it was using my old mocha.opts but it uses it's own config. Hope this helps.

@Gmadges
Copy link

Gmadges commented Sep 14, 2018

@jglover I had the same issue. Unexpectedly, I found swapping my single quotes 'test/**/*.ts' for double "test/**/*.ts" fixed it for me.

@hi-sunshine
Copy link

@jglover @4lph4-Ph4un I had the same issue with "webpack@4.28.3" and "mocha-webpack@2.0.0-beta.0". Have you fix it ? Any suggestion ?

@hi-sunshine
Copy link

@jglover @Gmadges I have the same issue. Is there any successful demo can show me ? thanks

@anlek
Copy link

anlek commented Apr 11, 2019

I'm in the same boat, anyone knows what caused this?

@anlek
Copy link

anlek commented Apr 11, 2019

For me, it seemed to be something to do with "Single File Components" in Vue and SCSS processing.
I patched it by just removing all CSS and SCSS rules and adding a null-loader for those:

// In my webpack-test-config.js
const newRules = config.module.rules.reduce((memo, r) => {
  if (r.test === undefined) return memo
  if (r.test.test('.css') || r.test.test('.scss')) return memo

  memo.push(r)
  return memo
}, [])

newRules.push({ test: /.(s)?css$/, loader: 'null-loader' })
config.module.rules = newRules

module.exports = config

Fixed my problem, however, I'm working on a large private project and I'm unable to share the code to help resolve the bug :(

@dagjomar
Copy link

dagjomar commented Jan 4, 2020

@anlek That tip did it for me!

I used a null-loader in my webpack.mocha.js config file

    {
      test: /\.(css|scss)$/,
      use: 'null-loader'
    },

Then specified that config file for mochapack to use. This is is my line in
This is my line in package.json:

"unit-tests": "mochapack --webpack-config config/webpack.mocha.js  --require 'src/test/setup.js' --reporter spec --colors --glob '*.test.js' src --recursive"

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

7 participants