Skip to content

Commit

Permalink
Speed up 'dead' tests by adding bailouts, except for 'timeout' test c…
Browse files Browse the repository at this point in the history
…ases
  • Loading branch information
Krinkle committed Jan 24, 2025
1 parent 1b8801a commit 50c1cf4
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 49 deletions.
1 change: 0 additions & 1 deletion test/fixtures/console.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>console</title>
<script>
console.log('TAP version 13');

Expand Down
1 change: 0 additions & 1 deletion test/fixtures/fail-and-timeout.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>timeout-fail</title>
<script>
console.log('TAP version 13');
function delay(ms, fn) {
Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/fail-and-uncaught.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>uncaught-mid</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
Expand All @@ -14,4 +13,8 @@
setTimeout(() => {
bar(); // Uncaught ReferenceError
}, 200);

setTimeout(() => {
console.log('Bail out! End of fixture'); // Don't wait for timeout
}, 300);
</script>
1 change: 0 additions & 1 deletion test/fixtures/fail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>fail</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/mocking.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>mocking</title>
<script>
window.XMLHttpRequest = function () {
throw new Error('Oops, called mock XMLHttpRequest');
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/pass.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>pass</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/skip.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>skip</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/slow.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>slow</title>
<script>
function delay(ms, fn) {
setTimeout(fn, ms);
Expand Down
6 changes: 0 additions & 6 deletions test/fixtures/timeout.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>timeout</title>
<script>
console.log('TAP version 13');
function delay(ms, fn) {
Expand All @@ -13,11 +12,6 @@

delay(3200, () => {
console.log('ok 3 Baz > another thing');

delay(4000, () => {
console.log('ok 4 Quux');
console.log('1..4');
});
});
});
});
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/todo.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>todo</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/uncaught-custom.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<title>uncaught-custom</title>
<script>
throw { message: 'Boo' };
</script>
<script>
setTimeout(function () {
console.log('Bail out! End of fixture'); // Don't wait for timeout
});
</script>
6 changes: 5 additions & 1 deletion test/fixtures/uncaught-early.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<title>uncaught-early</title>
<script>
bar(); // Uncaught ReferenceError
</script>
<script>
setTimeout(function () {
console.log('Bail out! End of fixture'); // Don't wait for timeout
});
</script>
1 change: 0 additions & 1 deletion test/fixtures/uncaught-late.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!DOCTYPE html>
<title>uncaught-late</title>
<script>
console.log('TAP version 13');
function delay(ms, fn) {
Expand Down
6 changes: 5 additions & 1 deletion test/fixtures/uncaught-mid.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<title>uncaught-mid</title>
<script>
console.log('TAP version 13');
console.log('ok 1 Foo bar');
bar(); // Uncaught ReferenceError
</script>
<script>
setTimeout(function () {
console.log('Bail out! End of fixture'); // Don't wait for timeout
});
</script>
6 changes: 5 additions & 1 deletion test/fixtures/uncaught-multiple.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<!DOCTYPE html>
<title>uncaught-multiple</title>
<script>
bar(); // Uncaught ReferenceError
</script>
<script>
quux(); // Uncaught ReferenceError
</script>
<script>
setTimeout(function () {
console.log('Bail out! End of fixture'); // Don't wait for timeout
});
</script>
55 changes: 26 additions & 29 deletions test/qtap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const __dirname = path.dirname(__filename);
const root = path.join(__dirname, '..');
const options = {
root,
timeout: 2,
timeout: 30,
verbose: !!process.env.CI,
// verbose: true, // debugging
printDebug: (str) => { console.error('# ' + str); }
Expand Down Expand Up @@ -55,11 +55,14 @@ QUnit.module('qtap', function () {
},
failAndTimeout: {
files: 'test/fixtures/fail-and-timeout.html',
options,
options: {
...options,
timeout: 5
},
expected: [
'client: running test/fixtures/fail-and-timeout.html',
'online',
'bail: Browser idle for 2s',
'bail: Browser idle for 5s',
],
exitCode: 1
},
Expand All @@ -69,8 +72,8 @@ QUnit.module('qtap', function () {
expected: [
'client: running test/fixtures/fail-and-uncaught.html',
'online',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/fail-and-uncaught.html:15',
'bail: Browser idle for 2s',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/fail-and-uncaught.html:14',
'bail: End of fixture',
],
exitCode: 1
},
Expand Down Expand Up @@ -109,10 +112,7 @@ QUnit.module('qtap', function () {
},
qunitPass: {
files: 'test/fixtures/qunit-pass.html',
options: {
...options,
timeout: 30,
},
options,
expected: [
'client: running test/fixtures/qunit-pass.html',
'online',
Expand All @@ -122,10 +122,7 @@ QUnit.module('qtap', function () {
},
qunitNotests: {
files: 'test/fixtures/qunit-notests.html',
options: {
...options,
timeout: 30,
},
options,
expected: [
'client: running test/fixtures/qunit-notests.html',
'online',
Expand All @@ -135,10 +132,7 @@ QUnit.module('qtap', function () {
},
qunitFail: {
files: 'test/fixtures/qunit-fail.html',
options: {
...options,
timeout: 30,
},
options,
expected: [
'client: running test/fixtures/qunit-fail.html',
'online',
Expand Down Expand Up @@ -168,11 +162,14 @@ QUnit.module('qtap', function () {
},
timeout: {
files: 'test/fixtures/timeout.html',
options,
options: {
...options,
timeout: 5
},
expected: [
'client: running test/fixtures/timeout.html',
'online',
'bail: Browser idle for 2s',
'bail: Browser idle for 5s',
],
exitCode: 1
},
Expand All @@ -192,8 +189,8 @@ QUnit.module('qtap', function () {
expected: [
'client: running test/fixtures/uncaught-early.html',
'online',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-early.html:4',
'bail: Browser idle for 2s',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-early.html:3',
'bail: End of fixture',
],
exitCode: 1
},
Expand All @@ -203,8 +200,8 @@ QUnit.module('qtap', function () {
expected: [
'client: running test/fixtures/uncaught-mid.html',
'online',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-mid.html:6',
'bail: Browser idle for 2s',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-mid.html:5',
'bail: End of fixture',
],
exitCode: 1
},
Expand All @@ -224,8 +221,8 @@ QUnit.module('qtap', function () {
expected: [
'client: running test/fixtures/uncaught-custom.html',
'online',
'consoleerror: Error: Boo\n at /test/fixtures/uncaught-custom.html:4',
'bail: Browser idle for 2s',
'consoleerror: Error: Boo\n at /test/fixtures/uncaught-custom.html:3',
'bail: End of fixture',
],
exitCode: 1
},
Expand All @@ -235,14 +232,14 @@ QUnit.module('qtap', function () {
expected: [
'client: running test/fixtures/uncaught-multiple.html',
'online',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-multiple.html:4'
+ '\nReferenceError: quux is not defined\n at /test/fixtures/uncaught-multiple.html:7',
'bail: Browser idle for 2s',
'consoleerror: ReferenceError: bar is not defined\n at /test/fixtures/uncaught-multiple.html:3'
+ '\nReferenceError: quux is not defined\n at /test/fixtures/uncaught-multiple.html:6',
'bail: End of fixture',
],
exitCode: 1
},
}, async function (assert, params) {
assert.timeout(10_000);
assert.timeout(40_000);

const run = qtap.run(
'firefox',
Expand Down

0 comments on commit 50c1cf4

Please sign in to comment.