avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Watch mode not respecting ignoredByWatcher #2957

Closed razor-x closed 2 years ago

razor-x commented 2 years ago

When running a test that saves files to tmp/some-dir/some-file AVA will loop forever in watch mode even if ignoredByWatcher is set. Same behaviour in AVA v3 and v4.

Minimal reproducible example: https://github.com/rxbugs/ava-watch-ignore

Arch Linux

node version    
v16.13.2

AVA version
4.0.1 or 3.15.0
{
  "ignoredByWatcher": ["tmp/**/*"]
}
{
  "type": "module",
  "scripts": {
    "test:watch": "ava -w",
    "test": "ava"
  },
  "devDependencies": {
    "ava": "^4.0.1",
    "mkdirp": "^1.0.4"
  }
}
import path from 'path'
import { promises as fsPromises } from 'fs'

import test from 'ava'
import mkdirp from 'mkdirp'

test.beforeEach(async (t) => {
  const root = 'tmp'
  await mkdirp(root)
  t.context.dst = await fsPromises.mkdtemp(path.join(root, 'foo-'))
})

test('bug', async (t) => {
  await fsPromises.writeFile(path.join(t.context.dst, 'foo'), 'bar')
  t.pass()
})
novemberborn commented 2 years ago

Your configuration isn't being picked up. AVA only support JavaScript configuration files, so you'd want something like ava.config.js:

export default {
  "ignoredByWatcher": ["tmp/**/*"]
}
razor-x commented 2 years ago

Your configuration isn't being picked up. AVA only support JavaScript configuration files, so you'd want something like ava.config.js:

export default {
  "ignoredByWatcher": ["tmp/**/*"]
}

🤦🏻 Thank you. I feel I can't be the only one who missed this change. Can I suggest a waring like this? https://github.com/avajs/ava/pull/2962