Experimenting with Nuxtjs application using AVA and TypeScript

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()
})

Answer №1

It has been noted in this source that Ava does not automatically detect typescript file extensions. To address this, it appears that integrating https://github.com/avajs/typescript is necessary. It is recommended to refer to the README provided by the latter repository for guidance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using the ternary operator in React to implement inline styles

Within my React/Typescript project, I aim to dynamically exhibit a color based on the presence or absence of a value in payload[1]. In the code snippet below, note the usage of an inline style tag. <li className="recharts-tooltip-item" style={ ...

Verify FileReader.onload function using Jasmine and AngularJS

I have a unique directive specifically designed for uploading and importing binary files. This directive listens for a change event on an <input type="file"../> element. Currently, I am facing an issue with the code coverage of my test. Although the ...

The code splitting feature in Nuxt is currently experiencing issues

Recently, I've started working with nuxtjs and currently have 2 pages set up: -index -map The map page contains a single client-only component, while the default layout includes links to both pages. However, when I build the production version, the ...

Troubleshooting: Why is the Vue search feature in v-data-table not functioning properly

My issue involves using computed values to populate my v-data-table, and I am struggling to resolve the search functionality. Additionally, I would like to re-enable column sorting if possible. Below is the code for my v-Data-Table: <v-data-table ...

The for each loop fails to return the value

In my Vue component, I have a conditional loop that iterates through train stations with 'New York' as the destination or on the route. <tr v-for="departure in filterTrainStations" :key="departure.name"> <td>{{ departure. ...

Guide for adjusting icon dimensions in Material-UI breakpoints

import { Container } from "@mui/material"; import * as React from "react"; import { Home } from "@mui/icons-material"; import PersonIcon from "@mui/icons-material/Person"; import FormatListBulletedIcon from "@mu ...

Form for creating and updating users with a variety of input options, powered by Angular 2+

As I work on creating a form, I encounter the need to distinguish between two scenarios. If the user selects 'create a user', the password inputs should be displayed. On the other hand, if the user chooses to edit a user, then the password inputs ...

I encountered TS2345 error: The argument type X cannot be assigned to the parameter type Y

Currently, I am delving into the world of Angular 8 as a beginner with this framework. In my attempt to design a new user interface with additional elements, I encountered an unexpected linting error after smoothly adding the first two fields. The error m ...

Nuxt 3: Accessing the contents of a slot

Here is the code snippet for my component. I am incorporating VueUse as well, and I aim to activate the "onClickOutside" function of vueUse when a click occurs outside the slot element. However, I have been facing challenges in identifying the c ...

Troubleshooting Checkbox Validation Problem in Vue JS

Deactivating Vue js Validation In the following piece of code, I am trying to disable a checkbox when item.status == "active". I attempted to use :disbale="item.status='active'"" in my checkbox. With this code snippet, the ...

Can you point me in the direction of the Monaco editor autocomplete feature?

While developing PromQL language support for monaco-editor, I discovered that the languages definitions can be found in this repository: https://github.com/microsoft/monaco-languages However, I am struggling to locate where the autocompletion definitions ...

Access an object within the ngOnInit lifecycle hook

Is there a way to access an object from the ngOnInit function and use it outside the class in the same component? Let me explain: I am implementing an Angular Material table and want to dynamically populate it with data retrieved from Firebase. ngOnIn ...

I recently updated all my projects to Angular 14, but when I tried to install a package using `npm i`, it still

The challenge at hand I encountered an issue with my two Angular projects. The first project serves as a library utilized by the second project. I recently upgraded both projects to Angular 14 following this guide. However, after running an npm i on the ...

TSLint Errors Update: The configuration provided cannot locate implementations for the following rules

After upgrading my tslint to version 4.0.2, I encountered numerous errors like the ones shown below: Could not find implementations for the following rules specified in the configuration: directive-selector-name component-selector-name directi ...

Replace the default Material UI 5.0 typography theme with custom fonts on a global scale

My current challenge involves incorporating two personal fonts into the Material UI 5.0. My goal is to apply these fonts globally by overriding the theme settings. However, I have encountered issues with loading the fonts properly and modifying the typogra ...

Creating a String-only pattern Validator: A step-by-step guide

Below is the code I've written: ***<input type="text" placeholder="First Name" name="firstName1" [(ngModel)]="firstName" #firstName1="ngModel" required pattern="^[a-z0-9_-]{8,15}$" >*** ...

Deploy Vue.js and ASP.NET Core together on Azure Cloud

I have a project that combines ASP.NET Core with Vue.js and I am trying to deploy it on Azure App Service using a CI/CD GitHub account. Following Microsoft's guide, everything seemed to be going smoothly until I encountered an error during the publish ...

Creating a TypeScript interface for Immutable.js objects: A step-by-step guide

Imagine we are working with the following interface User: interface User { id: number; name: string; bag: Item[]; } Now, let's create a React component: interface UserComponentProps { user: User; } interface UserComponentState {} class Use ...

Utilizing VueJs @error handler for managing broken image links

I am encountering a strange issue with the VueJS @error handler. My goal is to hide images with broken links and display a placeholder instead. However, when I have two images with broken links, only the first image displays the placeholder while the other ...

Guide to connecting a value within a component to an element in App.vue

I'm looking to dynamically assign a class to an element in App.vue based on a property or value from each page component. It's kind of like the opposite of passing a prop, not quite child -> parent or parent -> child. I've tried using ...