I've been experiencing 2 issues with .only since 2.0.0 (or maybe earlier, I can't remember for sure). I believe the issues persisted in 2.1.0 and 2.2.0.
My typical workflow is:
ava test/test-tiny-atom.js -vw.onlyExpected behaviour:
Actual behaviour:
Reproducable tests in the following repo: https://github.com/KidkArolis/tiny-atom. But I've been experiencing this issue with all of my repos using ava.
does not mutate the state object test runs twice
Copy the relevant section from package.json:
"ava": {
"files": [
"test/test-*.js"
],
"require": [
"@babel/register",
"./test/helpers/setup.js"
]
},
ava test/test-tiny-atom.js -vw
os darwin 18.7.0
node 10.15.3
ava 2.1.0
npm 6.10.0
@KidkArolis can you reproduce this with master?
I'm still seeing one bug though:
a.test.js and b.test.js, two tests in eachb.test.js, mark a test as .onlya.test.js. The .only tests runs, as expected https://github.com/avajs/ava/blob/master/docs/recipes/watch-mode.md#watch-mode-and-the-only-modifier.only from b.test.jsI think somehow the a.test.js file gets flagged as having exclusive tests, which isn't true. And then the watcher gets stuck until you re-run all tests.
Tried master (with npm i avajs/ava).. but ava -w is just hanging with the spinner stuck â ™, not sure why.
I had some trouble myself. There's some changes in Node.js 12.7.0 which may be impacting us. Maybe give it a go when once I get the next release out.
I think somehow the
a.test.jsfile gets flagged as having exclusive tests, which isn't true. And then the watcher gets stuck until you re-run all tests.
I think the problem is in this line https://github.com/avajs/ava/blob/master/lib/watcher.js#L232:
this.updateExclusivity(evt.testFile, fileStats.declaredTests > fileStats.selectedTests);
On step 4, when you save a.test.js, it has no tests selected to run, so declaredTests=2 and selectedTests=0 and it gets marked has exclusive. I think it should have an additional check for fileStats.selectedTests > 0 to make sure it did have a subset of tests to run (i.e. .only)
I think it should have an additional check for
fileStats.selectedTests > 0to make sure it did have a subset of tests to run (i.e..only)
That sounds like it'll do the trick.
@vmlf01 that solved it for me, see https://github.com/avajs/ava/pull/2216.
@KidkArolis 2.3.0 is out with watcher fixes. Please file a new issue if you're still having trouble after upgrading.
Oh! This is great! Thanks for quick action.
Seems to be working well for the most part - adding .only runs the one test, removing .only runs all tests - just as you'd expect.
However, I still noticed the issue where ava was running the same .only test twice:

But can't reproduce anymore. I'll open a new issue if I can isolate how that happens.