Skip to content

Commit

Permalink
Tests: Split up fixture output files
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Apr 9, 2024
1 parent da8d57e commit b22d7b0
Show file tree
Hide file tree
Showing 85 changed files with 1,074 additions and 1,094 deletions.
315 changes: 223 additions & 92 deletions test/cli/cli-main.js

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions test/cli/custom-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ const NPMReporter = require('npm-reporter');

const findReporter = require('../../src/cli/find-reporter').findReporter;

const expectedOutput = require('./fixtures/expected/tap-outputs');
const { execute, prettyPrintCommand } = require('./helpers/execute');

function getExpected (command) {
return expectedOutput[prettyPrintCommand(command)];
}
const { execute } = require('./helpers/execute');

QUnit.module('find-reporter', function () {
QUnit.test('tap reporter is bundled', function (assert) {
Expand Down Expand Up @@ -40,20 +35,29 @@ QUnit.module('CLI Reporter', function () {
const command = ['qunit', '--reporter', 'npm-reporter'];
const execution = await execute(command);

assert.equal(execution.snapshot, getExpected(command));
assert.equal(execution.snapshot, `Run ended!`);
});

QUnit.test('exits early and lists available reporters if reporter is not found', async function (assert) {
const command = ['qunit', '--reporter', 'does-not-exist'];
const execution = await execute(command);

assert.equal(execution.snapshot, getExpected(command));
assert.equal(execution.snapshot, `# stderr
No reporter found matching "does-not-exist".
Built-in reporters: console, tap
Extra reporters found among package dependencies: npm-reporter
# exit code: 1`);
});

QUnit.test('exits early and lists available reporters if reporter option is used with no value', async function (assert) {
const command = ['qunit', '--reporter'];
const execution = await execute(command);

assert.equal(execution.snapshot, getExpected(command));
assert.equal(execution.snapshot, `# stderr
Built-in reporters: console, tap
Extra reporters found among package dependencies: npm-reporter
# exit code: 1`);
});
});
11 changes: 11 additions & 0 deletions test/cli/fixtures/_load-default.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# name: load "test" directory by default
# command: ["qunit"]

TAP version 13
ok 1 First > 1
ok 2 Second > 1
1..2
# pass 2
# skip 0
# todo 0
# fail 0
14 changes: 14 additions & 0 deletions test/cli/fixtures/_load-dir-file-glob.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# name: load mixture of file, directory, and glob
# command: ["qunit","test","basic-one.js","glob/**/*-test.js"]

TAP version 13
ok 1 Single > has a test
ok 2 A-Test > derp
ok 3 Nested-Test > herp
ok 4 First > 1
ok 5 Second > 1
1..5
# pass 5
# skip 0
# todo 0
# fail 0
11 changes: 11 additions & 0 deletions test/cli/fixtures/_load-dir.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# name: load a directory
# command: ["qunit","test"]

TAP version 13
ok 1 First > 1
ok 2 Second > 1
1..2
# pass 2
# skip 0
# todo 0
# fail 0
7 changes: 7 additions & 0 deletions test/cli/fixtures/_load-filenotfound.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# name: load file not found
# command: ["qunit","does-not-exist.js"]

# stderr
No files were found matching: does-not-exist.js

# exit code: 1
11 changes: 11 additions & 0 deletions test/cli/fixtures/_load-glob.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# name: load glob pattern
# command: ["qunit","glob/**/*-test.js"]

TAP version 13
ok 1 A-Test > derp
ok 2 Nested-Test > herp
1..2
# pass 2
# skip 0
# todo 0
# fail 0
12 changes: 12 additions & 0 deletions test/cli/fixtures/_load-multiple-files.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# name: load multiple files
# command: ["qunit","basic-one.js","basic-two.js"]

TAP version 13
ok 1 Single > has a test
ok 2 Double > has a test
ok 3 Double > has another test
1..3
# pass 3
# skip 0
# todo 0
# fail 0
10 changes: 10 additions & 0 deletions test/cli/fixtures/_load-single-file.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# name: load single file
# command: ["qunit","basic-one.js"]

TAP version 13
ok 1 Single > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0
File renamed without changes.
21 changes: 21 additions & 0 deletions test/cli/fixtures/assert-expect-failure.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# name: assert.expect() different count
# command: ["qunit", "assert-expect-failure.js"]

TAP version 13
not ok 1 failing test
---
message: Expected 2 assertions, but 1 were run
severity: failed
actual : null
expected: undefined
stack: |
at /qunit/test/cli/fixtures/assert-expect-failure.js:1:7
at internal
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1

# exit code: 1
21 changes: 21 additions & 0 deletions test/cli/fixtures/assert-expect-no-assertions.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# name: assert.expect() no assertions
# command: ["qunit", "assert-expect-none.js"]

TAP version 13
not ok 1 no assertions
---
message: Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.
severity: failed
actual : null
expected: undefined
stack: |
at /qunit/test/cli/fixtures/assert-expect-none.js:1:7
at internal
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1

# exit code: 1
File renamed without changes.
13 changes: 13 additions & 0 deletions test/cli/fixtures/async-module-warning-promise.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# name: module() with promise
# command: ["qunit","async-module-warning-promise.js"]

TAP version 13
ok 1 module manually returning a promise > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0

# stderr
Returning a promise from a module callback is not supported. Instead, use hooks for async behavior. This will become an error in QUnit 3.0.
File renamed without changes.
13 changes: 13 additions & 0 deletions test/cli/fixtures/async-module-warning.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# name: module() with async function
# command: ["qunit","async-module-warning.js"]

TAP version 13
ok 1 resulting parent module > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0

# stderr
Returning a promise from a module callback is not supported. Instead, use hooks for async behavior. This will become an error in QUnit 3.0.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions test/cli/fixtures/callbacks-rejected.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# name: rejection from callbacks
# command: ["qunit", "callbacks-rejected.js"]

TAP version 13
not ok 1 global failure
---
message: Error: begin
severity: failed
stack: |
Error: begin
at /qunit/test/cli/fixtures/callbacks-rejected.js:8:25
at qunit.js
at internal
...
Bail out! Error: begin

# stderr
Error: Process exited before tests finished running

# exit code: 1
11 changes: 11 additions & 0 deletions test/cli/fixtures/config-filter-regex-exclude.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# name: config.filter with inverted regex
# command: ["qunit","config-filter-regex-exclude.js"]

TAP version 13
ok 1 filter > foo test
ok 2 filter > Bar test
1..2
# pass 2
# skip 0
# todo 0
# fail 0
12 changes: 12 additions & 0 deletions test/cli/fixtures/config-filter-regex.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# name: config.filter with a regex
# command: ["qunit","config-filter-regex.js"]

TAP version 13
ok 1 filter > foo test
ok 2 filter > FOO test
ok 3 filter > bar test
1..3
# pass 3
# skip 0
# todo 0
# fail 0
11 changes: 11 additions & 0 deletions test/cli/fixtures/config-filter-string.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# name: config.filter with a string
# command: ["qunit","config-filter-string.js"]

TAP version 13
ok 1 filter > foo test
ok 2 filter > bar test
1..2
# pass 2
# skip 0
# todo 0
# fail 0
10 changes: 10 additions & 0 deletions test/cli/fixtures/config-module.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# name: config.module
# command: ["qunit","config-module.js"]

TAP version 13
ok 1 Module B > Test B
1..1
# pass 1
# skip 0
# todo 0
# fail 0
14 changes: 14 additions & 0 deletions test/cli/fixtures/config-moduleId.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# name: config.moduleId
# command: ["qunit", "config-moduleId.js"]

TAP version 13
ok 1 module A scoped > module C nested > test C1
ok 2 module D scoped > test D1
ok 3 module D scoped > module E nested > test E1
ok 4 module D scoped > test D2
ok 5 module F flat > test F1
1..5
# pass 5
# skip 0
# todo 0
# fail 0
File renamed without changes.
20 changes: 20 additions & 0 deletions test/cli/fixtures/config-noglobals-add.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# name: config.noglobals and add a global
# command: ["qunit", "config-noglobals-add.js"]

TAP version 13
not ok 1 adds global var
---
message: Introduced global variable(s): dummyGlobal
severity: failed
actual : null
expected: undefined
stack: |
at qunit.js
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1

# exit code: 1
File renamed without changes.
10 changes: 10 additions & 0 deletions test/cli/fixtures/config-noglobals-ignored.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# name: config.noglobals and add ignored DOM global
# command: ["qunit", "config-noglobals-ignored.js"]

TAP version 13
ok 1 adds global var
1..1
# pass 1
# skip 0
# todo 0
# fail 0
20 changes: 20 additions & 0 deletions test/cli/fixtures/config-noglobals-remove.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# name: config.noglobals and remove a global
# command: ["qunit","config-noglobals-remove.js"]

TAP version 13
not ok 1 deletes global var
---
message: Deleted global variable(s): dummyGlobal
severity: failed
actual : null
expected: undefined
stack: |
at qunit.js
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1

# exit code: 1
File renamed without changes.
21 changes: 21 additions & 0 deletions test/cli/fixtures/config-requireExpects.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# name: assert.expect() missing and config.requireExpects=true
# command: ["qunit","config-requireExpects.js"]

TAP version 13
not ok 1 passing test
---
message: Expected number of assertions to be defined, but expect() was not called.
severity: failed
actual : null
expected: undefined
stack: |
at /qunit/test/cli/fixtures/config-requireExpects.js:3:7
at internal
...
1..1
# pass 0
# skip 0
# todo 0
# fail 1

# exit code: 1
13 changes: 13 additions & 0 deletions test/cli/fixtures/config-testId.tap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# name: config.testId
# command: ["qunit","config-testId.js"]

TAP version 13
ok 1 test 2
ok 2 module A > module B > test 1
ok 3 module A > module C > test 2
ok 4 module D > test 1
1..4
# pass 4
# skip 0
# todo 0
# fail 0

0 comments on commit b22d7b0

Please sign in to comment.