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

Ava unit tests failing with TypeScript ("SyntaxError: Unexpected identifier")

I'm learning TypeScript and I created a TypeScript React app with create-react-app. It uses a separate TypeScript file, logic.ts, which in turn imports a JSON file import pastaData from './data/users-pasta.json' const ParsedUserData =…
Cerulean
  • 5,543
  • 9
  • 59
  • 111
0
votes
1 answer

In AVA How can I import a variable from a test file to another test file

I am using AVA for testing. I have 2 files. In file1.spec.js, I am creating a user, and once the user is created a userId is generated and returned. I need this userId in file2.spec.js to test some other API calls specific to this user. How can I…
0
votes
0 answers

Run puppeteer before tests and pass page to tests

I want to start a puppeteer instance in ava before all tests and pass the page to all tests, so I can work with that active puppeteer instance. I'm using TypeScript and have followed these…
muuvmuuv
  • 901
  • 2
  • 13
  • 39
0
votes
0 answers

Run an Ava assertion after a Sinon assertion is true

I'm testing a module I'm developing in Ava. In one test, I provide something in the class constructor which causes the constructor to call an async function that defines a property to the class. I need to use this property to test something, but I'm…
exoRift
  • 531
  • 1
  • 5
  • 13
0
votes
1 answer

Occassional EACCES error running selenium tests in ava

On Windows 10 1809 the following errors gets thrown. I am using chrome for my tests. Error message 1 Frequency: About every 50th driver instantiation. [...]project\node_modules\selenium-webdriver\net\portprober.js:159 Rejected promise returned…
Adrian Dymorz
  • 875
  • 8
  • 25
0
votes
1 answer

Running selenium tests on IE 11 on Windows 10 1809 - no new windows open

On my test machine, I am able so start my test, but after several internet explorer windows get opened and closed by the test, no more new windwos are opened. I get no error mesage and the test is stuck. I checked every single setting according to…
Adrian Dymorz
  • 875
  • 8
  • 25
0
votes
1 answer

Testing js/esm project w/ sinon, nyc and ava - test w/ spy on console fails despite console log

I have an esm project I'm trying to test with ava, nyc and sinon. I have had some success using sinon to spy on console.log and report whether or not it is being called, but on another set of files, where I feel I'm doing the same things, I can't…
James South
  • 534
  • 4
  • 15
0
votes
1 answer

Ava and permissions with docker volume folder on electron project

My project is contained from the following files with respective permissions: -rw-r--r-- 1 pcmagas pcmagas 761 Νοέ 20 18:08 .compilerc -rw-rw-r-- 1 pcmagas pcmagas 1034 Νοέ 23 19:11 docker-compose.yml -rw-rw-r-- 1 pcmagas pcmagas 334…
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
0
votes
0 answers

Unexpected Token when trying to import a Vue component to test it with Ava

I have a Nuxt project containing a test file under test/index.test.js and I'm trying to test individual components by mounting them like so: import { Index } from './../pages/Index.vue' import { mount } from '@vue/test-utils' test.beforeEach(() =>…
Christopher
  • 1,712
  • 2
  • 21
  • 50
0
votes
1 answer

Function.prototype.apply was called on #, which is a object and not a function
I am using node-js and I have this line of code in a file called utils.js: const spartial = (func, ...args) => (...rest) => func(...args, ...rest); The file App.js contains a class called App and this class is using the spartial function in…
David Callanan
  • 5,601
  • 7
  • 63
  • 105
0
votes
1 answer

Sinon stub error: "Attempted to wrap post which is already wrapped" even though I'm restoring

I have a set of Ava tests using Sinon for stubs. I have several test cases like this one: test('makes a post request', t => { const postStub = sinon.stub(request, 'post').resolves({ foo: 'bar' }); ... some test stuff ... …
Joe Attardi
  • 4,381
  • 3
  • 39
  • 41
0
votes
2 answers

ava dynamic syntax import enable support

I'm trying to enable dynamic import syntax in my ava config. I found that standard configuration (and other) from this subject doesn't work ava: SyntaxError: Unexpected token import. My project is really simple . ├── package.json ├── router │   └──…
tstr
  • 1,254
  • 20
  • 35
0
votes
1 answer

How to check if a method is called before another one got called

I have a method called mainMethod() and it returns a promise. This method contains several methods m1(), m2()...,m5(). Now I am making a unit test using sinon, I want to check if m1() is called and m2() is not called. Because I have an array that…
Amrmsmb
  • 1
  • 27
  • 104
  • 226
0
votes
1 answer

How can NPM run a command that isn't in path

The ava command is not in my path. I can not run it from in the project directory that contains some AVA tests. My npm test command of my project is set to ava tests/*.js --verbose, and can somehow call the ava command from the same location in the…
tehp
  • 5,018
  • 1
  • 24
  • 31
0
votes
1 answer

How to prevent ava displaying long objects when a test fails

Given: Express app, AVA, supertest When: I test generated html in response and the test case fails Then: AVA displays the whole response object in the console which slows down analysis of the issue Example of the test: test('Positive case: book is…
Sergiy Seletskyy
  • 16,236
  • 7
  • 69
  • 80