Louis Charles
Louis Charles

Reputation: 360

Cannot add a watcher to my test scripts with vue-utils

I am trying to add a watcher in my "test" script I defined in the package.json.

What I want to achieve is quite simple : I want the command line "npm run test" to be executed each time I modify a file that ends with .spec.js in the tests/FrontEnd directory.

What I get when I run "npm run test" are the following lines :

enter image description here

This is how I've modified the script to get the watcher :

    "test": "mocha-webpack --webpack-config=node_modules/laravel-mix/setup/webpack.config.js --require tests/Frontend/setup.js tests/Frontend/**/*.spec.js --watch"

Everything works when I remove the --watch at the end of my script.

My dependencies versions are here :

"devDependencies": {
        "@nuxtjs/vuetify": "^1.10.1",
        "@vue/test-utils": "^1.0.0-beta.32",
        "axios": "^0.19",
        "bootstrap": "^4.4.1",
        "cross-env": "^5.2.1",
        "css-loader": "^3.4.2",
        "deepmerge": "^4.2.2",
        "expect": "^25.1.0",
        "fibers": "^4.0.2",
        "jquery": "^3.4.1",
        "jsdom": "^16.2.1",
        "jsdom-global": "^3.0.2",
        "json-loader": "^0.5.7",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.13",
        "mocha": "^4.0.1",
        "mocha-webpack": "^0.7.0",
        "popper.js": "^1.12",
        "preload-webpack-plugin": "^3.0.0-beta.4",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.26.2",
        "sass-loader": "^7.3.1",
        "style-loader": "^1.1.3",
        "vue": "^2.6.11",
        "vue-template-compiler": "^2.6.11",
        "vue-test-utils": "^1.0.0-beta.11",
        "webpack": "^4.42.0"
    },

Thanks for the help !

Upvotes: 1

Views: 87

Answers (1)

Kashyap
Kashyap

Reputation: 4796

This looks like an incompatibility of the mocha-webpack plugin version you're using and the webpack plugin you're using. The 0.7.0 version of mocha-webpack is written for an older webpack plugin system, and as such might not work with the newer one. In the webpack version you're using 4.20.0 (approx), the chunk property does not have the property/accessor of modules, and that's where you see the error.

And this code path is run only in watch mode (from what I was able to gather from that version's codebase), so this didn't happen when you didn't provide --watch.

Try upgrading the mocha-webpack plugin to the latest stable version.

Upvotes: 1

Related Questions