bencodezen / vue-enterprise-boilerplate

An ever-evolving, very opinionated architecture and dev environment for new Vue SPA projects using Vue CLI.
7.78k stars 1.32k forks source link

Relative test with lint-staged not being found #179

Closed marceloavf closed 4 years ago

marceloavf commented 4 years ago

When I change login.vue for example, and it goes to git staged, lint-staged can't find the test next to it, or lint-staged should be passing the unit test file automatically with login.vue ?

Only if I modify the .unit.js test itself to stop the commit with the error, but for that, I also have to change yarn test:unit:file to yarn test:unit --passWithNoTests --bail in lint staged config file.

Lint staged debug log

2019-10-22T13:06:53.550Z lint-staged:task cmd: git
2019-10-22T13:06:53.550Z lint-staged:task args: [ 'add', 'd:/projects/bluedesk/src/router/views/login.vue' ]
2019-10-22T13:06:53.550Z lint-staged:task execaOptions: { preferLocal: true,
  reject: false,
  shell: false,
  cwd: 'd:/projects/bluedesk' }
git add [completed]
yarn test:unit:file [started]
2019-10-22T13:06:53.588Z lint-staged:task cmd: yarn
2019-10-22T13:06:53.588Z lint-staged:task args: [ 'test:unit:file',
  'd:/projects/bluedesk/src/router/views/login.vue' ]
2019-10-22T13:06:53.588Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
yarn test:unit:file [completed]
Running tasks for *.js [completed]
yarn test:unit:file [completed]
Running tasks for *.vue [completed]
Running tasks... [completed]
2019-10-22T13:06:55.815Z lint-staged tasks were executed successfully!
Done in 7.06s.

When I run direct in bash:

$ yarn && yarn test:unit:file d:/projects/bluedesk/src/router/views/login.vue
yarn install v1.19.1
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.78s.
yarn run v1.19.1
$ yarn test:unit --bail --findRelatedTests d:/projects/bluedesk/src/router/views/login.vue
$ cross-env VUE_APP_TEST=unit vue-cli-service test:unit --bail --findRelatedTests d:/projects/bluedesk/src/router/views/login.vueer/views/login.vue
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in D:\projects\bluedesk.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: d:\\projects\\bluedesk\\src\\router\\views\\login.vue - 0 matches
Done in 1.88s.
EgorFront commented 4 years ago

I have same issue.

I have cloned a clean repository and the yarn test:unit:file command does not work.

The problem seems to be in the --findRelatedTests flag The test runs only if you specify the path to the test file

like: yarn test:unit:file .\src\components\_base-button.unit.js runs the test, but yarn test:unit:file .\src\components\_base-button.vue not working

I assume this problem is only on windows OS

image

UPD I finally fixed that problem, I'll make PR as soon as possible