Ava: How to prevent AVA from asserting unrelated files I'm importing?

Created on 8 Jul 2018  Â·  1Comment  Â·  Source: avajs/ava

Description

I am importing a setup object to use in all my tests. However, I'm not sure how to prevent AVA from trying to assert the imported object. In my case this object is called store and is a Vuex store.

Test Source

import test from 'ava'
import store from '../dist/test/setup/index.cjs.js'

test('mutations', t => {
  const mutations = store._mutations
  const expectedMutations = ['pokemonBox']
  expectedMutations.forEach(m => t.true(
    Object.keys(mutations).includes(m)
  ))
})

Error Message & Stack Trace

3 exceptions
  ✖ No tests found in test/setup/config.js, make sure to import "ava" at the top of your test file
  ✖ test/setup/index.js exited with a non-zero exit code: 1
  ✖ test/setup/store.js exited with a non-zero exit code: 1

Environment

Node.js v10.1.0
darwin 17.6.0
fish: Unknown command 'ava'
fish:
ava --version
^
5.6.0

Most helpful comment

From the docs:

Directories are recursed, with all *.js files being treated as test files. Directories named fixtures, helpers and node_modules are always ignored. So are files starting with _ which allows you to place helpers in the same directory as your test files.

So you need to either put the setup directory inside a directory named helpers or explicitly ignore that folder by specifying the globs to your test files in the files option or explicitly ignore that directory.

>All comments

From the docs:

Directories are recursed, with all *.js files being treated as test files. Directories named fixtures, helpers and node_modules are always ignored. So are files starting with _ which allows you to place helpers in the same directory as your test files.

So you need to either put the setup directory inside a directory named helpers or explicitly ignore that folder by specifying the globs to your test files in the files option or explicitly ignore that directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

electerious picture electerious  Â·  3Comments

clitetailor picture clitetailor  Â·  3Comments

ehmicky picture ehmicky  Â·  4Comments

OmgImAlexis picture OmgImAlexis  Â·  3Comments

ivogabe picture ivogabe  Â·  5Comments