-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
t.plan is slow #1
Comments
Just for reference: import test from 'ava';
for(var i = 0; i < 10000; i++) {
test(`test${i}`, t => {
if (process.env.PLAN) {
t.plan(1);
}
t.pass();
});
} Results:
|
👍 Can you open an issue/PR on AVA about it? |
avajs/ava#482 mitigated most of the downside:
|
I will open a PR, but I think I'll play down the performance concern. I don't want people to avoid a good tool because they think it's "slow". |
@jamestalmage Yeah, the perf difference is negligible now. I mostly want it because of best practises. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, thanks for doing this. The AVA team appreciates it.
t.plan
is pretty slow. It actually generates an Error and captures the stack trace every time you call it.It's totally unnecessary for most sync tests, the only times you absolutely should use it are when there is branching or async behavior that might skip an assertion:
Promise based tests with a
.catch
followed by.then
Guaranteeing multiple callbacks are called
Ensuring a catch statement happens
I am not arguing with your findings here. I am sure they are accurate. I am also sure your use of
t.plan
is not the only (or even primary) reason AVA is slower.@sindresorhus - Maybe this should end up as a recipe as well.
The text was updated successfully, but these errors were encountered: