Questions tagged [mocha-webpack]

Precompiles server-side webpack bundles before running mocha. Inspired by karma-webpack alternatives usage, but this is for Node.js!

Precompiles your server-side webpack bundles before running mocha. Inspired by karma-webpack alternatives usage, but this is for Node.js!

39 questions
33
votes
7 answers

How to fix "Error: Expected to be running in 'ProxyZone', but it was not found." in mocha testing?

I am trying to test my Tour of Heroes Angular application using mocha, chai & webpack. I have followed this post & also with the help of this guide, have gone through the setup and got the build errors fixed and tests up and running. But, my tests…
Kushan
  • 407
  • 1
  • 7
  • 11
13
votes
1 answer

how to separate files for mocha-webpack

What's happening is that when I run my tests, my coverage only shows bundle.js which isn't that helpful. I have the following webpack file setup and wanted to know what I should change to make it so that each file is covered…
A. L
  • 11,695
  • 23
  • 85
  • 163
6
votes
0 answers

Generating nyc coverage report for VueJS project with @vue/cli-plugin-unit-mocha, TypeScript and SFC's

I am currently working on setting up a testing environment for a Vue project that uses the @vue/cli-plugin-unit-mocha to run unit tests. The project uses TypeScript and .vue Single-File-Components. I have successfully set-up my project to run unit…
4
votes
0 answers

How to watch mocha-webpack tests results in mocha-test-explorer VS Code Extension?

I'm working on a just created Vue cli project with TypeScript and unit testing. I Know that Vue cli tests uses mocha-webpack to runt tests. And when I Type mocha-webpack on terminal, the tests runs ok. But I would like to use an mocha-test-explorer,…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
3
votes
0 answers

Root Hooks in Mocha

I am just experimenting with Mocha and Mochapack and wanting to set up a Root Hook to fire before every test. According to the Mocha docs, I should place my hooks in a module and "require" them with the --require flag. My NPM command is: "test":…
Zakalwe
  • 1,444
  • 3
  • 14
  • 25
3
votes
0 answers

Openlayers 6 TypeError: URL.createObjectURL is not a function

I have a question, after i update the openlayers from 5.3.1 to 6.3.1, when i run test, jest or mocha, both show the error "TypeError: URL.createObjectURL is not a function", what is the reason? Mocha-Webpack: TypeError: URL.createObjectURL is not a…
3
votes
1 answer

How to configure debug for vue mocha unit tests in VS Code?

I have managed to start debugger, but it looks like VS Code do not see the sourcemap. When I add debugger JS statement, it breaks in webpack generated file main.js (that do not event exists in file system) but using this is painfull. I have next…
3
votes
1 answer

Testing Vue Component: Failed to mount component: template or render function not defined

I'm writing a test for a Vue component using Mocha and I can't seem to resolve this warning: [Vue warn]: Failed to mount component: template or render function not defined. After a bit of research, it seems like most other instances of this warning…
Ben Downey
  • 2,575
  • 4
  • 37
  • 57
3
votes
1 answer

Mocha with webpack can not resolve module

I was trying to run mocha tests in my project. When i execute npm command i get the next error: > Frontent@0.0.0 test /home/serperga/falcon/falcon-project/frontend > mocha-webpack ERROR in…
Sergio P.
  • 41
  • 1
  • 7
2
votes
1 answer

VueJS Component: Code coverage for separate file with vue-class-component

I am trying to generate code coverage for VueJS components that are written in TypeScript using vue-class-component decorators, and with separate .ts files for the actual logic of the component. E.g. for one VueJS component I have effectively two…
2
votes
1 answer

mocha-webpack ReferenceError: window is not defined

I use NodeJS and mocha-webpack as a testing tool. Then I get an error in the terminal: ReferenceError: window is not defined ... I have in package.json: "scripts": { "tws": "mocha-webpack -r ./test/test*.js", "tw": "mocha-webpack --watch…
Roman
  • 19,236
  • 15
  • 93
  • 97
2
votes
1 answer

How do you get the 'this' variable defined in a vuejs component unit test

I am trying to use mocha-webpack in an npm script to test a vuejs component. I am mocking the vuex store like this in the test: const vm = new Vue({ template: '
', store: new Vuex.Store(mockedStore), …
Scott Anderson
  • 988
  • 3
  • 11
  • 25
2
votes
1 answer

How to exclude "node_modules"

How can I exclude node_modules from the run? I thought that webpack-node-externals were meant for this task. This is my webpack.test-config.js: const nodeExternals = require('webpack-node-externals'); const config = {}; // in order to ignore…
Amio.io
  • 20,677
  • 15
  • 82
  • 117
1
vote
0 answers

Vue.js unit tests error Module not found: 'canvas' in amcharts4

When I execute the test with vue-cli-service, I imported a component that contain amcharts4 to spec file then run command vue-cli-service test:unit I got the error Module not found: 'canvas' in…
Ivo Mullen
  • 11
  • 1
1
vote
1 answer

Laravel with vuejs unit test mocha-webpack script error

I am going to test vue components in Laravel application environment. My package.json "scripts" are following: "scripts": { "dev": "npm run development", "development": "cross-env NODE_ENV=development…
1
2 3