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

How to check if a vlues lays within a specific range of values

I am using ava testingUnit and I want to know how to check if the value i receive is within a specific range. For example, I have a method that shuffles an array and picks an item from that array randomly. Let's consider that example, the method…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
0
votes
1 answer

AVAjs - Plugin or preset file babel-preset-react/lib/index.js did not export a function

I am trying to configure AVAjs with React. So here is my AVA config inside package.json: "ava": { "files": [ "test/**/*.spec.js" ], "sources": [ "**/*.{js,jsx}", "!dist/**/*" ], "concurrency": 4, "failFast": true, "failWithoutAssertions":…
Alessander França
  • 2,697
  • 2
  • 29
  • 52
0
votes
1 answer

HowTo test Micro EndPoints with Ava and Test-Listen

Let's say I have this routes.js in micro: const hello = async (req, res) => { send(res, 200, `Hello, ${req.params.who}`); }); module.exports = router( post('/hello/:who', hello), ); I have the following test set-up, but unfortunately I am…
Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147
0
votes
2 answers

Readable stream `_read` not called in test

I have the following simplified ava test case. When I run it by ava _read() never get called (ONDATA is OK). On the other hand, when I run this test body (without assertions) as node script I always get _read() called as expected. Probably I miss…
0
votes
2 answers

How to make sure that a method is called only once given specific parameters

i have a class called Feature and it contains the following methods setUser(boolean),execute(), doExecute() And according to the below stated parameters, when i call execute() method, doExecute() method should be called only once. I tried to test…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
0
votes
2 answers

JavaScript: How to use WebStorm debugger with ava

This is not question, just answer: Create run/debug configuration, type Node.js Select your node interpreter As node parameter insert your ava bin and parameter --verbose For me it's: ./node_modules/.bin/ava --verbose Select your working…
0
votes
1 answer

How to test my controllers?

I am using Express to build a REST API. The code is divided, as should be, in Routes/Models/Controllers (no views, it's just JSON) The controllers take care of the logic : they make request to the database and build the responses. To me, this is the…
Magix
  • 4,989
  • 7
  • 26
  • 50
0
votes
0 answers

Promise.all vs looping in AVA test

I am using a mongo in memory test fixture loader that gets primed before each test. Normally works flawlessly. I have a function getSample that makes a db call that I test using AVA. Wanting to call this multiple time with different parameters…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
0
votes
1 answer

Module did not self register with Talib and AVA

I'm getting a Module did not self register error I am unable to get rid of using talib and ava. I have tried Node 8.9.0 as well as 9.0.0, upgraded AVA and tried stable and dev branches of talib. I am running test serially as well. And of course I…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
0
votes
1 answer

Multiple callbacks in ava.js

I have a callback that I want to see if its called twice. I have looked into t.plan and in the FAQ it says its a good use case for t.plan but you have to explicitly define t.end(). But in my case its the same callback. How is this possible?
vaughan
  • 6,982
  • 6
  • 47
  • 63
0
votes
1 answer

ava dependencies missing from package-lock.json after upgrading it

I have just upgraded ava in one of my projects using npm install --save-dev ava@0.22.0. To my surprise, all its dependencies are now missing from package-lock.json: Added: + "version": "0.22.0", + "resolved":…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
0
votes
1 answer

the use of the RxJS delay operator within Ava tests

I'm the author of a JavaScript program which needs to be executed against a number of tests. I discovered that each of these tests follow a similar format and as such it's appropriate to generate the tests using a factory function. The factory…
user2245766
  • 301
  • 1
  • 10
0
votes
1 answer

Vuejs testing - Ava - Changing propData

Im trying to change the propData passed into a component to monitor and check the component. Im expecting the last console log in this code block to be 5 but its still 2. import Vue from 'vue'; import test from 'ava'; import AnimateNumber from…
Peter I
  • 843
  • 1
  • 9
  • 31
0
votes
2 answers

How to use Ava with Angular/CLI build typescript project

As a part of a project I am building I currently have an angular/cli typescript project I have created. We are currently using the karma testing framework, but are extremely interested in switching to AVA if possible. I've currently done a npm…
Slushba132
  • 423
  • 2
  • 5
  • 20
0
votes
2 answers

Assertion error using ava

First my english not good but this test fail for me. test('get user', async t => { let db = t.context.db t.is(typeof db.getUser, 'function', 'getUser is a function') let user = fixtures.getUser() let created = await db.saveUser(user) let…