Questions tagged [ava]

AVA is a fast and simple JavaScript test runner with builtin support for ES2015.

Links

Description

Even though JavaScript is single-threaded, IO in Node.js can happen in parallel due to its async nature. AVA takes advantage of this and runs your tests concurrently, which is especially beneficial for IO heavy tests. In addition, test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file.

Highlights

  • Minimal and fast
  • Simple test syntax
  • Runs tests concurrently
  • Enforces writing atomic tests
  • No implicit globals
  • Isolated environment for each test file
  • Write your tests in ES2015
  • Promise support
  • Generator function support
  • Async function support
  • Observable support
  • Enhanced asserts
  • Optional TAP output
  • Clean stack traces

Example test syntax

import test from 'ava';

test(t => {
    t.is(foo(), 'foo');
});
209 questions
1
vote
0 answers

How to mock ClientProxy microservice for nestjs in ava test framework

I am trying to give the mock data in ClientProxy but I am keep on receiving null. It could be because of returning Observable. But I cannot figure it out how to properly mock the result. I am using ava framework to write the tests test('get user…
JN_newbie
  • 5,492
  • 14
  • 59
  • 97
1
vote
1 answer

Passing arguments to AVA test files

I'm looking for ways to pass arguments to my ava test file via command line and I found this documentation. https://github.com/avajs/ava/blob/main/docs/recipes/passing-arguments-to-your-test-files.md // test.js const test =…
jialeee17
  • 601
  • 2
  • 7
  • 12
1
vote
0 answers

ava throws npm ERR! Test failed when sinon stub throws new error

I have below test which hits an endpoint. The service method stub throws an error. Any error throws in app is handled by global error handler, and the handler return an error with status 500 like: { success: false, message: "Something went…
confusedWarrior
  • 938
  • 2
  • 14
  • 30
1
vote
1 answer

How to implement recursion for data comparison function?

I have this helper function in my app that tells me the changes of newData when compared to oldData. How can I refactor my getChanges function to make the test below pass? I thought I may need to make this function recursive since it executes itself…
LovelyAndy
  • 841
  • 8
  • 22
1
vote
1 answer

Typescript edge cases mess up test coverage

I have a project set up to use the AVA test runner and the NYC coverage tool. I am sure that I have 100% test coverage. However, because I am using typescript, it seems that the typescript compiler added a bunch of polyfills with edge cases that…
Jake
  • 2,090
  • 2
  • 11
  • 24
1
vote
0 answers

Why does nyc only capture files from the main process of my Electron process?

I use ava in combination with the testing framework nyc for my Electron app. After executing my tests I noticed that only files from the main process are captured. My package.json looks like this: "ava-ts": "nyc --reporter=html --reporter=text…
Daniel Stephens
  • 2,371
  • 8
  • 34
  • 86
1
vote
1 answer

Get number of concurrent tests running in AVA

I have test cases that are failing due timestamp differences as a result of a lot of tests running at once. I want to adjust the difference depending on the number of test cases running at point in time. Is there a way to get the number of test…
Joseph Woolf
  • 500
  • 5
  • 14
1
vote
1 answer

Can I somehow declare that a test expects to have unhandled rejections?

I have a library that imposes "metering" on some code. The normal case is easy to test where the code runs to completion and the meter is not exceeded. I also want to test the case where the meter is exceeded, causing the code under test to throw…
1
vote
1 answer

excluded files are not being skipped

so I have the following files setup "files" : [ "testing/tests/**", "!testing/tests/**/__helpers__/*", ], However, files in the __helpers__ folder are not being skipped ✖ No tests found in…
A. L
  • 11,695
  • 23
  • 85
  • 163
1
vote
1 answer

AVA Test Fails in case of accessing global variable

We've recently started migrating tests for database models. Facing an issue while trying to separate out different type of tests in different files. I am writing some AVA unit tests In one file test_1.js it is, const test = require('ava'); const…
mrhassan
  • 196
  • 1
  • 10
1
vote
1 answer

Testing Nuxtjs App with AVA and TypeScript

I'm creating a Nuxt app with TypeScript and want to unit test with AVA. However when I try to run a test I get: ✖ Couldn't find any files to test I have @nuxt/typescript-build installed and added to my nuxt.config.js Project structure (excluding…
Zoford
  • 123
  • 8
1
vote
1 answer

Is there a way to set rest configuration headers from property file values?

Here I'm trying to access the global property from properties file and set it in enableCORS header in rest configuration like
Tarun
  • 61
  • 6
1
vote
1 answer

How to have test execution skipped based on some condition (let's say environment variable) using AVA framework

I need to skip some tests base on the condition. Due to the current framework setup the best possibility would be to use environment variable. Something like test.before(() => {if(skipAll==true) skipAllTests();})
O'Leg
  • 79
  • 1
  • 9
1
vote
2 answers

trying to setup ava unit testing for a next.js project but getting two errors related to the setup

working through setting up ava testing within my package.json file. However when I try to run the test from the command line getting this following error: throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof…
Dan
  • 361
  • 1
  • 5
  • 17
1
vote
0 answers

Testing @nuxtjs/axios using avajs

I have not been able to figure out how to use avajs to test @nuxtjs/axios. Does anyone have a working example? Here's a stub of what I tried: import axios from '@nuxtjs/axios'; localVue.use(axios); When I do this, I get the following error: …
gsharp
  • 27
  • 5