MCPcopy Create free account
hub / github.com/nodejs/node / test

Function test

test/fixtures/wpt/resources/testharness.js:624–653  ·  view source on GitHub ↗

* Create a synchronous test * * @param {TestFunction} func - Test function. This is executed * immediately. If it returns without error, the test status is * set to ``PASS``. If it throws an :js:class:`AssertionError`, or * any other exception, the test status is set to ``FA

(func, name, properties)

Source from the content-addressed store, hash-verified

622 * given file and must be invariant between runs.
623 */
624 function test(func, name, properties)
625 {
626 if (tests.promise_setup_called) {
627 tests.status.status = tests.status.ERROR;
628 tests.status.message = '`test` invoked after `promise_setup`';
629 tests.complete();
630 }
631 var test_name = get_test_name(func, name);
632 var test_obj = new Test(test_name, properties);
633 var value = test_obj.step(func, test_obj, test_obj);
634
635 if (value !== undefined) {
636 var msg = 'Test named "' + test_name +
637 '" passed a function to `test` that returned a value.';
638
639 try {
640 if (value && typeof value.then === 'function') {
641 msg += ' Consider using `promise_test` instead when ' +
642 'using Promises or async/await.';
643 }
644 } catch (err) {}
645
646 tests.status.status = tests.status.ERROR;
647 tests.status.message = msg;
648 }
649
650 if (test_obj.phase === test_obj.phases.STARTED) {
651 test_obj.done();
652 }
653 }
654
655 /**
656 * Create an asynchronous test

Callers 15

check-layout-th.jsFile · 0.70
idlharness.jsFile · 0.70
idl_testFunction · 0.70
generate_testsFunction · 0.70
prototypes.any.jsFile · 0.50
test_operationsFunction · 0.50
test_attributesFunction · 0.50
interface.any.jsFile · 0.50

Calls 3

get_test_nameFunction · 0.85
completeMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected