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

sinon.getCall(0).args[0] is returning the result of the function, not first arg

I am testing a small function using AVA and Sinon. Function looks essentially like this (edited for brevity): mergeDefaults: function (opts) { **console.log('log 1 ->', opts);** opts = _.defaultsDeep(opts, defaultOptions); return opts; } I…
0
votes
2 answers

How use AVA with JQuery in Typescript?

I try to test a lib with JQuery but I have an error. Example : import { test } from 'ava' import $ from 'jquery' import {fixture} from 'ava-browser-fixture' test.beforeEach('setup fixture', …
Karima Rafes
  • 1,016
  • 10
  • 19
0
votes
1 answer

Is there a way to detect an AssertionError in Ava

What I want to do is console.log something if there is a failure in an AVA test but I can't find any documentation on how to do this - if its possible. test.afterEach.always(t => { if(t.hasFailure()){ //something like this …
brommersman
  • 116
  • 1
  • 4
0
votes
2 answers

VUE: Ava can't run any assertion ERROR

My folder structure is this: ./package.json src/Notification.js test/notification.js File Notification.js export default { template: '
{{message}}
', data() { return { message: 'Hello world' }; } }; File…
Lluís Puig Ferrer
  • 1,128
  • 7
  • 19
  • 49
0
votes
1 answer

Supertest request with CSRF fails

I have an Express 4 application that makes user of csurf for CSRF protection on API routes. The application is working perfectly and CSRF protection is indeed working where requests without the csrf-token header will give the appropriate error. I…
kiyui
  • 375
  • 3
  • 14
0
votes
2 answers

Consecutive asynchronous test steps in ava

The problem The popular ava package features a simple and powerful testing framework for javascript: import test from 'ava'; test('single step', t => { t.is('bar', 'bar'); t.end(); }); Testing is dead simple for synchronous code. However,…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
0
votes
1 answer

Unit Test action dispatch using enzyme

I'm trying to write a simple unit test to make sure if the form inside a react component dispatches the expected action on submit. Code: Form submit action inside the component which I'm trying to test:
{ …
InquisitiveGirl
  • 667
  • 3
  • 12
  • 31
0
votes
1 answer

Having an issue interacting with pop-up window Webdriverio

I'm trying to interact with a pop-up PayPal window during my testing using selenium and webdriverio (I'm also using AVA as the test runner). I'm able to switch to the pop-up and when I test if a form element is enabled it returns true. However…
0
votes
1 answer

Converting TSV file to JSON using text2json return no value

I'm trying to convert a TSV file into JSON and write it to disk using text2json. Input data There is an empty line at the end U+2B695 shī U+2B699 pū U+2B6DB zhī U+2B6DE jué U+2B6E2 níng U+2B6F6 chì U+2B6F8 tí Test I've this test running with…
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
0
votes
1 answer

Ava unbinds this for t.throws

AVA seems to unbind the instance methods 'this'. class Person { constructor(name) { this.name = name; } sayMyName() { const name = this.name; return new Promise(function (resolve, reject) { reject(new…
Allen
  • 3,601
  • 10
  • 40
  • 59
0
votes
1 answer

Set up tests with Typescript and Ava : bad require

I'm setting up AVA with Typescript to tests my JS code. Internally, I'm first calling TSC to compile my files, then call AVA with babel-register to test them (Babel register allowing require to be resolved). "ava": "tsc && ava…
user3844028
0
votes
2 answers

Subsequent variable declarations must have the same type. any

I'm using ava (no link, since I'm not allowed to use more than 2 ) for testing and want to type ava's test context. It's typed as any in ava's definition file. What I specifically want is that the typescript compiler knows that t.context is of the…
despairblue
  • 347
  • 2
  • 8
0
votes
0 answers

Initially insert documents into DB

I want to test an express app with mongoose. Therefor I am using AVA and Mockgoose. Using the beforeEach hook of AVA I want to insert two documents into my database which I can then use in my tests. The code looks like follows: import test from…
user2030592
  • 317
  • 2
  • 12
0
votes
1 answer

AVA testing gives undefined when importing to test.js

I am using AVA as testing with node and javascript. On test.js import test from 'ava'; import {valid, output, input} from './dependency.js'; test("Input is not a Empty String", t => { t.not(input, ''); t.pass(); }) test("Correct output", t =>…
Yh1234
  • 141
  • 2
  • 12
0
votes
1 answer

React unit testing with Ava: Why is the function already wrapped?

Even though I am using the afterEach I still get the following error:Attempted to wrap setTimeout which is already wrapped.What am I doing wrong?I am using ava to do this unit test. The test I am trying to create is very simple. It is pretty much…
zeid10
  • 511
  • 8
  • 28
1 2 3
13
14