Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit-30 committed Feb 15, 2023
1 parent 091b0a9 commit 1512e10
Show file tree
Hide file tree
Showing 3 changed files with 299 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/message/test_runner_output_spec_reporter.js
Expand Up @@ -6,5 +6,5 @@ const child = spawn(process.execPath,
['--no-warnings', '--test-reporter', 'spec', 'test/message/test_runner_output.js'],
{ stdio: 'pipe' });
// eslint-disable-next-line no-control-regex
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '').replace(/[^\x00-\x7c]/g, '')));
child.stderr.pipe(process.stderr);
11 changes: 11 additions & 0 deletions test/message/test_runner_output_spec_reporter_with_coverage.js
@@ -0,0 +1,11 @@
// Flags: --no-warnings
'use strict';
require('../common');
const spawn = require('node:child_process').spawn;
const child = spawn(process.execPath,
['--no-warnings', '--test-reporter', 'spec',
'--experimental-test-coverage', 'test/message/test_runner_output.js'],
{ stdio: 'pipe' });
// eslint-disable-next-line no-control-regex
child.stdout.on('data', (d) => process.stdout.write(d.toString().replace(/[^\x00-\x7F]/g, '').replace(/\u001b\[\d+m/g, '')));
child.stderr.pipe(process.stderr);
287 changes: 287 additions & 0 deletions test/message/test_runner_output_spec_reporter_with_coverage.out
@@ -0,0 +1,287 @@
sync pass todo (*ms)
sync pass todo with message (*ms)
sync fail todo (*ms)
Error: thrown from sync fail todo
*
*
*
*
*
*
*

sync fail todo with message (*ms)
Error: thrown from sync fail todo with message
*
*
*
*
*
*
*

sync skip pass (*ms)
sync skip pass with message (*ms)
sync pass (*ms)
this test should pass
sync throw fail (*ms)
Error: thrown from sync throw fail
*
*
*
*
*
*
*

async skip pass (*ms)
async pass (*ms)
async throw fail (*ms)
Error: thrown from async throw fail
*
*
*
*
*
*
*

async skip fail (*ms)
Error: thrown from async throw fail
*
*
*
*
*
*
*

async assertion fail (*ms)
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

true !== false

*
*
*
*
*
*
* {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: true,
expected: false,
operator: 'strictEqual'
}

resolve pass (*ms)
reject fail (*ms)
Error: rejected from reject fail
*
*
*
*
*
*
*

unhandled rejection - passes but warns (*ms)
async unhandled rejection - passes but warns (*ms)
immediate throw - passes but warns (*ms)
immediate reject - passes but warns (*ms)
immediate resolve pass (*ms)
subtest sync throw fail
+sync throw fail (*ms)
Error: thrown from subtest sync throw fail
*
*
*
*
*
*
*
*
*
*

this subtest should make its parent test fail
subtest sync throw fail (*ms)

sync throw non-error fail (*ms)
Symbol(thrown symbol from sync throw non-error fail)

level 0a
level 1a (*ms)
level 1b (*ms)
level 1c (*ms)
level 1d (*ms)
level 0a (*ms)

top level
+long running (*ms)
'test did not finish before its parent and was cancelled'

+short running
++short running (*ms)
+short running (*ms)

top level (*ms)

invalid subtest - pass but subtest fails (*ms)
sync skip option (*ms)
sync skip option with message (*ms)
sync skip option is false fail (*ms)
Error: this should be executed
*
*
*
*
*
*
*

<anonymous> (*ms)
functionOnly (*ms)
<anonymous> (*ms)
test with only a name provided (*ms)
<anonymous> (*ms)
<anonymous> (*ms)
test with a name and options provided (*ms)
functionAndOptions (*ms)
escaped description \ # *
*
(*ms)
escaped skip message (*ms)
escaped todo message (*ms)
escaped diagnostic (*ms)
#diagnostic
callback pass (*ms)
callback fail (*ms)
Error: callback failure
*
*

sync t is this in test (*ms)
async t is this in test (*ms)
callback t is this in test (*ms)
callback also returns a Promise (*ms)
'passed a callback but also returned a Promise'

callback throw (*ms)
Error: thrown from callback throw
*
*
*
*
*
*
*

callback called twice (*ms)
'callback invoked multiple times'

callback called twice in different ticks (*ms)
callback called twice in future tick (*ms)
Error [ERR_TEST_FAILURE]: callback invoked multiple times
*
failureType: 'multipleCallbackInvocations',
cause: 'callback invoked multiple times',
code: 'ERR_TEST_FAILURE'
}

callback async throw (*ms)
Error: thrown from callback async throw
*
*

callback async throw after done (*ms)
only is set but not in only mode
running subtest 1 (*ms)
running subtest 2 (*ms)
running subtest 3 (*ms)
running subtest 4 (*ms)
only is set but not in only mode (*ms)

custom inspect symbol fail (*ms)
customized

custom inspect symbol that throws fail (*ms)
{ foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] }

subtest sync throw fails
sync throw fails at first (*ms)
Error: thrown from subtest sync throw fails at first
*
*
*
*
*
*
*
*
*
*

sync throw fails at second (*ms)
Error: thrown from subtest sync throw fails at second
*
*
*
*
*
*
*
*
*
*

subtest sync throw fails (*ms)

timed out async test (*ms)
'test timed out after *ms'

timed out callback test (*ms)
'test timed out after *ms'

large timeout async test is ok (*ms)
large timeout callback test is ok (*ms)
successful thenable (*ms)
rejected thenable (*ms)
'custom error'

unfinished test with uncaughtException (*ms)
Error: foo
*
*
*

unfinished test with unhandledRejection (*ms)
Error: bar
*
*
*

invalid subtest fail (*ms)
'test could not be started because its parent finished'

Warning: Test "unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
Warning: Test "async unhandled rejection - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
Warning: Test "immediate throw - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from immediate throw fail" and would have caused the test to fail, but instead triggered an uncaughtException event.
Warning: Test "immediate reject - passes but warns" generated asynchronous activity after the test ended. This activity created the error "Error: rejected from immediate reject fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.
Warning: Test "callback called twice in different ticks" generated asynchronous activity after the test ended. This activity created the error "Error [ERR_TEST_FAILURE]: callback invoked multiple times" and would have caused the test to fail, but instead triggered an uncaughtException event.
Warning: Test "callback async throw after done" generated asynchronous activity after the test ended. This activity created the error "Error: thrown from callback async throw after done" and would have caused the test to fail, but instead triggered an uncaughtException event.
tests 65
pass 27
fail 21
cancelled 2
skipped 10
todo 5
duration_ms *
start of coverage report
*
*
*
*
*
end of coverage report

0 comments on commit 1512e10

Please sign in to comment.