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
0
votes
1 answer

Difference between --timeout and t.timeout in ava

I am using the test framework ava and I have two ways of setting a timeout. Either through command-line via --timeout and also by code via t.timeout(..) The documentation states: AVA resets a timer after each test, forcing tests to quit if no new…
Daniel Stephens
  • 2,371
  • 8
  • 34
  • 86
0
votes
1 answer

Why is Ava js not showing error logging locally, only in ci

I have a failing ava test that should error out like this: $ npm run test > fetch_courses@1.0.0 test /home/travis/build/********/fetch_courses > tsc && ava Uncaught exception in test/fetchTerms.test.ts Error: Cannot find module '../config.js' …
notacorn
  • 3,526
  • 4
  • 30
  • 60
0
votes
1 answer

t.context scoping in ava

I'm 90% sure of what is causing the problem but I'd like to clarify how ava handles t.context. Here is my scenario: const lMockManager = ImportMock.mockClass(zmq, "Dealer"); lMockManager.mock(Symbol.asyncIterator,…
Oliver Chalk
  • 176
  • 4
  • 19
0
votes
1 answer

ava + ts-node converting .spec.ts files into .ts

I am running ava with ts-node with the following config: "ava": { "files": [ "tests/**/*", "!test/exclude-files-in-this-directory", "!**/exclude-files-with-this-name.*" ], "failFast": true, …
A. L
  • 11,695
  • 23
  • 85
  • 163
0
votes
2 answers

Ava js not executing tests

so I have an issue with ava >=3.0, with 2.4.0 all my tests are executing fine, I have a ts project a compile to js and execute all js test files. When migrating to 3.0 (or 3.8) I have tried both, I keep getting this error... ✖ Internal error …
rage77
  • 3
  • 4
0
votes
1 answer

How to replace Chai.js' `.deep.iterate.over` in AVA?

I'm currently in process of migrating a large set of tests from Mocha and Chai to AVA. Because of that, I sometimes have to replace some Chai.js assertions to use them in AVA, example: // Before expect(arr).to.be.iterable; // After t.is(typeof…
0
votes
1 answer

How to disable stack traces in AVA and show my own error messages on error

I use ava to test my Scheme interpreter in JavaScript, and I don't want to have stack traces on each failed assertion, I would like to have maybe custom reporter that will show which test failed and why and not show error that point usually to same…
jcubic
  • 61,973
  • 54
  • 229
  • 402
0
votes
1 answer

How to mock two axios call in same endpoint

Example: In my test I need to mock the two calls to the external apis. I can't mock on the second call. With the library 'axios-mock-adapter' and ava I could only mock the first call. const read = async (req, res) => { try { const responseOne…
sarten8
  • 23
  • 1
  • 6
0
votes
1 answer

Ava test setTimeout() on addEventListener()

I have this function which I want to test with ava and browser-env function foo () { setTimeout(() => { const event = new CustomEvent('pushcommand', { detail: 'foo', bubbles: true }) …
user670839
0
votes
1 answer

How to create parametric tests with Ava

Coming from Python, I am used to this syntax when writing parametric tests (hope it is self-explanatory): @pytest.mark.parametrize('a', [0, 1, 2]) @pytest.mark.parametrize('b', [0, 1, 2]) def test_sum(a, b): assert sum(a, b) == a + b The…
Peque
  • 13,638
  • 11
  • 69
  • 105
0
votes
1 answer

How can I use jest-specific-snapshot with ava?

I'm migrating my tests from jest to ava; in my jest setup, I used jest-specific-snapshot to have one snapshot file per testcase (I sometimes adjust my snapshots manually, and it's easier on my editor if not everything lives in one large file). Can…
retorquere
  • 1,496
  • 1
  • 14
  • 27
0
votes
1 answer

How to set an Alias in AVA tests

I'm trying to set alias globally in my project without using Webpack, Babel, etc. Right now I have a simple test with AVA. I'm using module-alias npm package that let me set in package.json my aliases. However, when I try to just create a simple…
Chumpocomon
  • 661
  • 1
  • 6
  • 12
0
votes
2 answers

Click function in Spectron doesn't click

I'm working on a electron(-nuxt) based application. End to End test re-written with AVA + Spectron. The .click() function however doesnt seem to work. I used this template: https://github.com/michalzaq12/electron-nuxt Everything seems to work except…
KingRazer
  • 3
  • 3
0
votes
1 answer

updated Ava configuration using babel

We have recently updated from ava 0.17.0 to version 2.4.0. The old configuration in the package.json no longer works and ava tests now fail. the old configuration in our package.json looks like the following "ava": { "timeout": "10m", …
Ray Collins
  • 23
  • 1
  • 3
0
votes
1 answer

ava support for snapshot property matchers

Does ava support snapshot property matchers? I am using ava snapshots to test an API endpoint that returns a JSON object. The response contains some properties that are unique to the request (e.g. timestamp, request id). I know that Jest allows to…
dlac
  • 315
  • 2
  • 9