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

ava watch functionality and transpiling typescript

Is it possible to use ava --watch functionality when i write the tests in typescript? Now I have something like this "test": "tsc -p tsconfig.test.json && ava \"dist_test/**/*.js\"" Only it would be nice to have it only test modified source / test…
Chris
  • 8,168
  • 8
  • 36
  • 51
4
votes
1 answer

Ava babel-register not transpiling

I'm trying to include Ava (migrating from mocha) as my test runner for a react / electron app. I've got this config in my package.json "ava": { "files": [ "./app/**/*.spec.js" ], "source": [ "./app/**/*.{js,jsx}" ], …
CWright
  • 2,068
  • 2
  • 16
  • 20
4
votes
2 answers

Are Enzyme / React shallow renders expensive?

We're having a discussion at work about Enzyme shallow renders and the time per test to re-run shallow on each test. Be it methods, clicks, selector lengths, etc., I'm suggesting that our tests might run faster if we shallow render the component one…
4m1r
  • 12,234
  • 9
  • 46
  • 58
4
votes
1 answer

AVA testing problems

I am trying to write a test using AVA but I can't seem to get it to work write. fn passes the callback function through all of my functions and calls it once it's done everything. My test is import test from 'ava'; import fn from…
SirParselot
  • 2,640
  • 2
  • 20
  • 31
3
votes
1 answer

Is it possible to test that a css style property exists for a React component using enzyme + ava?

I'm looking to test that a component has an opacity value of 0 after firing an event, I have not found how to get/check for a specific css property with enzyme (enzyme docs), is it even possible to do it just with enzyme & ava? Or is a third party…
sab
  • 1,454
  • 1
  • 14
  • 26
3
votes
1 answer

How to use code coverage in Electron app which uses Angular?

I write an Electron app (in TypeScript) that I test through AVA (in whose tests I use Spectron to communicate with the app). The (browser) content of my app is generated by using Angular. I execute the tests via: npm run ava All of this works…
Daniel Stephens
  • 2,371
  • 8
  • 34
  • 86
3
votes
1 answer

Unhandled promise rejection AVA

I want to use ava for test my code but when I try it I'm getting the following error... I think there is a catch (err) missing... (node:7640) UnhandledPromiseRejectionWarning: C:\...\TesBoard-db\node_modules\ava\lib\node-arguments.js:9 …
Davos MG
  • 33
  • 3
3
votes
0 answers

how to run nuxt ava e2e tests

I'm trying to follow the example here, but I get the following errors in my project: $ ava --serial --verbose Error occurred when calling nuxtServerInit: Cannot read property 'user' of undefined ✖ Route / exits and render HTML Rejected promise…
alexarsh
  • 5,123
  • 12
  • 42
  • 51
3
votes
1 answer

Ava additional babel plugins are not being run

I'm trying to use an additional babel plugin when running Ava to transpile react dynamic imports so they can run on node (based on this response) ava dynamic syntax import enable support I cannot add it to my main .babelrc file as we are…
3
votes
0 answers

bootstrap-vue, SyntaxError Unexpected identifier

When i run test with ava, problem occurs in component that includes vue-bootstrap import inside. import bDropdown from "bootstrap-vue/es/components/dropdown/dropdown" import bDropdownItem from…
3
votes
3 answers

mocking es6 modules in unit test

Suppose we have a file(source.js) to test: // source.js import x from './x'; export default () => x(); And the unit test code is very simple: // test.js import test from 'ava'; import source from './source' test("OK", t => { source(); …
Jim Jin
  • 1,249
  • 1
  • 15
  • 28
3
votes
2 answers

AVA: setup different timeout for each test case

I writing asynchronous tests using AVA, and need to setup custom timeout for each test cases. I've not found out any information about this possibility and my tests seems like this: import test from 'ava'; test.cb('super test', t => { …
Max Vinogradov
  • 1,343
  • 1
  • 13
  • 31
3
votes
2 answers

Run ava test.before() just once for all tests

I would like to use test.before() to bootstrap my tests. The setup I have tried does not work: // bootstrap.js const test = require('ava') test.before(t => { // do this exactly once for all tests }) module.exports = { test } //…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
3
votes
1 answer

Mocking named imports and constructors ES6 & Ava

I have a class constructor, with a function I want to stub: class Service { constructor(){} async someFunction() { try { // does stuff } catch (e) {} } } In the file I want to test, this is imported an used like so: const {…
fredmoon
  • 84
  • 10
3
votes
1 answer

How to group tests in AVA test runner?

First of all, thank you for this lib! My query, is there any way to group tests in AVA? Let's say I have four tests cases at present like: test('Group #1 - Test sum #1', t => t.is(m.sum(20, 10), 30)); test('Group #1 - Test sum #2', t =>…
palaѕн
  • 72,112
  • 17
  • 116
  • 136
1 2
3
13 14