Skip to content

Run test by order #1532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oknoorap opened this issue Sep 24, 2017 · 9 comments
Closed

Run test by order #1532

oknoorap opened this issue Sep 24, 2017 · 9 comments

Comments

@oknoorap
Copy link

I have config file:

"ava": {
    "files": [
      "test/01_init.js",
      "test/02_new.js",
      "test/03_cleanup.js"
    ]
  }

It seems that ava run test not by filename order, how to make ava run test by order? I've added serial in config or in cli arguments but it doesn't works too.

@novemberborn
Copy link
Member

AVA won't guarantee any particular execution order.

Why do you need this?

(I'm closing this issue, but please don't refrain from discussing it further.)

@johhansantana
Copy link

hey @novemberborn is there a way to run the tests file by file (I don't mind the order). Reason is, I need to be authenticated to do some tests and the authenticated user needs to be an admin. But each time I test something like this I have to clean up the user (remove it from admin role).

This conflicts if I have multiple tests doing the same thing ( I imagine, haven't tested yet ).

I use test.serial in a file and it works perfect (they get executed in order) but running multiple test files, it will try to test every file at the same time.

@novemberborn
Copy link
Member

@johhansantana try the --serial argument or serial option in AVA's package.json configuration.

@johhansantana
Copy link

@novemberborn wow, that's perfect, thanks!

@piercus
Copy link

piercus commented Sep 13, 2018

@novemberborn I would need to run tests in a specific order.

Reason is : I'm tracking an issue, which is occuring sometimes (but not every time) when running my test suite with ava.

I think it might be related to the order of test, like a test run A is corrupting another test run B.

Problem is : i have 37 tests and even if i know test B (because it is failing) it is very hard to track test run A if the order of test run is changing.

@novemberborn
Copy link
Member

@piercus the order within a test file is currently fixed, though asynchronous tests may complete in a different order based on the async APIs they're relying on.

The order by which test files run is not currently randomized, but we don't guarantee any particular order either.

#595 proposes we randomize the order, which as you found requires a way to reproduce that order, too. So ironically that would help you.

I would use the --verbose logging option to see if there's actually a difference between failing and passing test runs. That may give you a clue, or it could turn out that the failure is not related to the execution order at all.

@nordqvist
Copy link

For anybody looking for a solution for this, how i came around it was looping through the files and running the tests individually.

for file in {your test folder}/*; do echo '\n Testing' $file; ava $file || break; done

The || break is important, otherwise it will just go to the next test if you try to quit.

@GentileFulvio
Copy link

Why was this closed if I may ask ? Is there already a way to defined an order in which the test files should run ?

@novemberborn
Copy link
Member

@GentileFulvio this is a rather old issue. Perhaps you could post your question anew in our Discussions section?

@avajs avajs locked as resolved and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants