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

behaviour of test:unit --watch changed? #1391

Closed
doppelreim opened this issue May 29, 2018 · 8 comments
Closed

behaviour of test:unit --watch changed? #1391

doppelreim opened this issue May 29, 2018 · 8 comments

Comments

@doppelreim
Copy link

Version

3.0.0-beta.11

Reproduction link

https://github.com/doppelreim/vue-test-app/tree/test-watch-behaviour

Steps to reproduce

Install dependencies: npm install

Run the unit-tests in "watch-mode": ./node_modules/.bin/vue-cli-service test:unit --watch

After they have passed, open "Other.spec.ts" and change something. For example, change the expectation from 8 to 7.

Save the file.

The tests are run again, automatically (because of --watch)

What is expected?

At least in beta6, only the tests contained in the file that changed are run again.

What is actually happening?

In beta12, all tests are run again.


I'm not sure, what the actually intended behaviour is. Maybe it should always have been like this. But it is different :)

@yyx990803
Copy link
Member

This is fixed also by e17f78c

@Oliboy50
Copy link

Oliboy50 commented Jul 3, 2018

SEE EDIT MESSAGE BELOW

@yyx990803 the --watch option seems to be broken in the latest release (at least using the cli-plugin-unit-jest)

I tried both from the UI and from my own terminal, and both using npm and yarn:

  • the UI outputs nothing, it just waits
  • my own terminal outputs Determining test suites to run... and then waits
yarn run v1.7.0
$ vue-cli-service test:unit --watch
    "@vue/cli-plugin-unit-jest": {
      "version": "3.0.0-rc.3",
      "resolved": "https://registry.npmjs.org/@vue/cli-plugin-unit-jest/-/cli-plugin-unit-jest-3.0.0-rc.3.tgz",
      "integrity": "sha512-A+ktUdIL856YEpeUVYH+sxccJsgNQ4LA9zH7qNr1bN7pTPEBA7xTNWYbySucwYbhIex66fuRxzQ6Az6MK/DEyw==",
      "dev": true,
      "requires": {
        "@vue/cli-shared-utils": "^3.0.0-rc.3",
        "babel-jest": "^23.0.1",
        "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
        "jest": "^23.1.0",
        "jest-serializer-vue": "^1.0.0",
        "jest-transform-stub": "^1.0.0",
        "vue-jest": "^2.6.0"
      }
    },
    "@vue/cli-service": {
      "version": "3.0.0-rc.3",
...

    "jest": {
      "version": "23.1.0",
...

FYI, when I run the test:unit command without the --watch flag, the tests all run correctly.

EDIT: my bad, it seems to comes from jest itself... because I have the same issue by simply running node_modules/.bin/jest --watch
=> my issue is located here => jestjs/jest#4883 (it works when I use node_modules/.bin/jest --watchAll instead)

@factoidforrest
Copy link

what is the solution?

@RickMeijer
Copy link

Old issue, but maybe some lone googler can use this: For me running npm run test:unit -- --watch works as expected on a newly instantiated project.

See https://docs.npmjs.com/cli/run-script

npm will pass all the arguments after the -- directly to your script:

@aniforprez
Copy link

Trying to send --watch as an option always gives me the following error

Error: `fsevents` unavailable (this watcher can only be used on Darwin)
    at new FSEventsWatcher (/Users/anirudhs/Documents/personal-projects/reddit-saved/node_modules/sane/src/fsevents_watcher.js:41:11)
    at createWatcher (/Users/anirudhs/Documents/personal-projects/reddit-saved/node_modules/jest-haste-map/build/index.js:780:23)
    at Array.map (<anonymous>)
    at HasteMap._watch (/Users/anirudhs/Documents/personal-projects/reddit-saved/node_modules/jest-haste-map/build/index.js:936:44)
    at _buildPromise._buildFileMap.then.then.hasteMap (/Users/anirudhs/Documents/personal-projects/reddit-saved/node_modules/jest-haste-map/build/index.js:355:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)

@ezpzlmnsqz1337
Copy link

ezpzlmnsqz1337 commented Jun 24, 2019

Old issue, but maybe some lone googler can use this: For me running npm run test:unit -- --watch works as expected on a newly instantiated project.

See https://docs.npmjs.com/cli/run-script

npm will pass all the arguments after the -- directly to your script:

This worked for me, after 1 day of trying almost everything, this finally worked!

EDIT: Funny, I have to have in package.json "test:unit": "vue-cli-service test:unit" and run it like npm run test:unit -- --watch, if I put the parameters in the test:unit script directly in package json, it is not working.

EDIT2: My bad, "test:unit": "vue-cli-service test:unit --watch" works just fine

@aniforprez
Copy link

Yo thanks for reminding me. The error fixed itself when I reinstalled the supported version of jest. I'm happy you found this after 1 day. I tried so many things for 2 days until I found this ridiculously simple solution. I felt like a fool 😭

@baamenabar
Copy link

baamenabar commented Nov 8, 2019

I just added "test:unit:watch": "vue-cli-service test:unit --watch" to the scripts section in my package.json, works like a charm.

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

8 participants