I'm in the process of developing a Nuxt application using TypeScript and intend to conduct unit testing with AVA. Nonetheless, upon attempting to run a test, I encounter the following error message:
✖ No test files were found
The @nuxt/typescript-build
package has been installed and included in my nuxt.config.js
Below is an outline of the project structure (excluding items like package.json):
- components/
- CardItem.vue
- test/
- specs/
-CardItem.spec.ts
- ava.setup.js
- ava.config.cjs
- nuxt.config.js
- tsconfig.json
This represents my configuration file for ava.config.cjs
:
module.exports = () => {
return {
require: ['./test/ava.setup.js'],
ignoredByWatcher: ['!**/*.{js,vue}'],
babel: true,
tap: false,
verbose: false,
color: true
}
}
This is the content of ava.setup.js
:
require('browser-env')()
const hooks = require('require-extension-hooks')
const Vue = require('vue')
Vue.config.productionTip = false
window.Date = global.Date = Date
hooks('vue')
.plugin('vue')
.push()
hooks(['vue', 'js'])
.exclude(({ filename }) => filename.match(/\/node_modules\//))
.plugin('babel')
.push()
Here is the setup from my tsconfig.json
:
{
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"moduleResolution": "node",
"lib": ["esnext", "esnext.asynciterable", "dom"],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"@/*": ["./*"]
},
"types": ["@types/node", "@nuxt/types"]
},
"exclude": ["node_modules"]
}
Lastly, here is the content of CardItem.spec.ts
:
import test from 'ava'
import { shallowMount } from '@vue/test-utils'
import CardItem from '@/components/CardItem.vue'
test('renders it\'s graphic', async t => {
const wrapper = shallowMount(CardItem)
t.fail()
})