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
3
votes
0 answers

Can't import sass file with webpack using ava

I'm trying to test a React component with ava that also uses webpack. When I try to import styles from sass, the ava tests throw. How could I fix that? import './index.scss' SyntaxError: /src/index.scss: Unexpected token (1:0) > 1 | .wrapper { |…
Cameron
  • 2,427
  • 1
  • 22
  • 27
3
votes
1 answer

AVA test setup: "Unexpected token export"

Problem I'm trying to add AVA tests to a project and my tests are not parsing ES2015 modules correctly with my Babel setup. What is odd to me is the imports are working fine and if I run my npm run build and run the output from the REPL it…
user3773571
2
votes
3 answers

How to mock or stub process.argv

How do I mock or stub process.argv so that it can return a specific argument? I tried using Sinon.js like this: beforeEach( () => { sandbox.stub( process.argv.slice(2)[0], 'C:\\home\\project\\assignment' ).value('--local'); …
2
votes
1 answer

What is assertion methods?

I'm learning AVAJS recently. One thing that sounds kind of abstract to me is 'assertion methods', or simply assertion. For example: What is it, or what it actually does in programming. I'm looking for some easy-understanding docs to read up. Any…
jialeee17
  • 601
  • 2
  • 7
  • 12
2
votes
0 answers

mocking global objects for AVA

Learning AVA.js test runner It is not clear how can I mock global objects (e.g. Date, Math etc.) as long as the tests run in parallel so such object patching becomes concurrent. How should one really go with it?
BuffUp
  • 21
  • 1
2
votes
1 answer

Testing code that uses process.on('unhandledRejection') with AVA

How do I use AVA to test a library that registers an unhandledRejection callback: process.on('unhandledRejection', e => // do something effectful ); In this environment, unhandled rejections are not necessarily errors in the library. I…
2
votes
0 answers

istambul nyc fails to detect any files when running ava test suite

Started trying to integrate nyc/istambul into my ava test suites: ./node_modules/.bin/nyc --include modules/todo.js --es-modules ./node_modules/.bin/ava 1 tests passed ----------|---------|----------|---------|---------|------------------- …
Mark Tyers
  • 2,961
  • 4
  • 29
  • 52
2
votes
1 answer

Assert That "expect" Called X Times in Jest

How can I fail the test if expect was not called at all? Or even better, when it was not called X times? For example: it('should fail', () => { if (1 === 2) { expect(1).toEqual(1) } } In other words, what is the equivalent of…
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
2
votes
1 answer

What do I name my files? How do I run a single test?

In jest one names a file thing.jest.ts. You can then run jest thing.jest.ts or point jest at a folder of test files eg jest some_folder/sub_folder. How do I do this with AVA? Things that don't work: Can't use wildcards $ ava /**/*.test.ts ✖…
Seph Reed
  • 8,797
  • 11
  • 60
  • 125
2
votes
1 answer

Ava separate integration and unit tests

I'd like to use 'ava' tool for both unit and integration testing. But I can't figure out what's the best way to separate those tests. Unit tests should run before the code deployed into test environment, and integration tests need to run after the…
Vlad
  • 9,180
  • 5
  • 48
  • 67
2
votes
1 answer

AVA unit tests fails passed Javascript test specs

I am currently working with ES6 modules with .mjs extensions and creating test cases for some functions. I have chosen AVA due to its support of this extension type but the test executions are not running as expected. I assume the script is not…
O.O
  • 1,389
  • 14
  • 29
2
votes
1 answer

How to trigger keyup with enter key

When writing unit tests with ava and vuejs how can I trigger the Enter keyup event? For example, with the following component how can I test that someFunction has been called?
waghcwb
  • 357
  • 6
  • 12
2
votes
0 answers

Vue component import aliasing for NuxtJS for ava test-runner and vue-test-utils

I'm having an error on my component testing when there is a vue mixin on it Uncaught exception in test/specs/Logo.spec.js /home/sprguillen/Workspace/unit-test/components/Logo.vue:7 6:
7:
The Bassman
  • 2,241
  • 5
  • 26
  • 38
2
votes
2 answers

Does AVA have a default for timeouts?

The documentation mentions the ability to configure a timeout, but it neglects to mention the default state. I'll try and look at the source code to figure this out to post a helpful answer here shortly. https://github.com/avajs/ava
wurde
  • 2,487
  • 2
  • 20
  • 39
2
votes
3 answers

Access multiple renderers with spectron

I'm working on an Electron application. The main process opens a first renderer (browserWindow). When the user click on a button, this renderer sends an IPC message to the main process. When this message is received, the main process opens a second,…
Anozer
  • 421
  • 1
  • 4
  • 12