-
Notifications
You must be signed in to change notification settings - Fork 95
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
pta reports PASS 0 before passing Zora tests finish running #188
Comments
I meant to post this as a |
Thanks for the report. Do you have the same problem if you install pta on your machine and run it directrly (without npx) ? |
There's no difference between the two: Versions
Install pta# to prevent from mistakenly polluting the `package.json`:
pushd /tmp/
npm install --location=global pta@1
popd Install Zoranpm install --save-dev zora@5 Bogo tests
"use strict";
let Zora = require("zora");
Zora.test("sync:pass", function (t) {
t.ok(true);
});
Zora.test("sync:fail", function (t) {
t.ok(false);
});
Zora.test("sync:timeout", function () {
// do nothing
});
Zora.test("async:pass", async function (t) {
await sleep(50);
t.ok(true);
});
Zora.test("async:fail", async function (t) {
await sleep(50);
t.ok(false);
});
Zora.test("async:timeout", async function () {
await sleep(50);
// do nothing
});
Zora.test("cb:pass", function (t) {
let p = sleep(50).then(function () {
t.ok(true);
});
return p;
});
Zora.test("cb:fail", function (t) {
let p = sleep(50).then(function () {
t.ok(false);
});
return p;
});
Zora.test("cb:timeout", function () {
let p = sleep(50).then(function () {
// do nothing
});
return p;
});
async function sleep(ms) {
return await new Promise(function (resolve) {
setTimeout(resolve, ms);
});
} Run testsnpm ci
pta 'tests/**/*.js' Result
|
Also note that zora sums the number of tests incorrectly:
There were 9 tests. 3 should have passed and 6 should have failed (3 timeouts). |
Note quite. In TAP protocol, a "test" is actually an assertion. Your timeout cases have no assertion. There is indeed a timeout check but it is by default 5s not 50ms. You can overwrite that value by test, or globally with an env variable (or with a command line option when using pta). see documentation |
I see the problem. Pta imports zora singleton to hold its reporting and load the spec files. With your setups it loads zora from a different file and therefore "hold" a different singleton (because we need a file for commonjs, es, etc..). You can either install pta locally to your project or as you use commonjs, get the same result with basic bash command in your npm script:
where "zr" is zora reporter you can install |
Good news!
In another release or two it will no longer be necessary to do import and transpile gymnastics! |
I'm a little confused because this outputs
PASS: 0
before Zora finishes running the very first test (which passes with 2 tests).What did I do wrong?
The text was updated successfully, but these errors were encountered: