Skip to content

Commit

Permalink
test: migrate tests to use node:test module for better test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Mert Can Altin committed Nov 27, 2024
1 parent 585f7bc commit c086664
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
29 changes: 16 additions & 13 deletions test/sequential/test-debugger-custom-port.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
'use strict';
const common = require('../common');

common.skipIfInspectorDisabled();

const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const assert = require('node:assert');
const { test } = require('node:test');

const assert = require('assert');
// Skip if the inspector is disabled
common.skipIfInspectorDisabled();

// Custom port.
const script = fixtures.path('debugger', 'three-lines.js');
test('should start CLI debugger with custom port and validate output', async (t) => {
const script = fixtures.path('debugger', 'three-lines.js');
const cli = startCLI([`--port=${common.PORT}`, script]);

const cli = startCLI([`--port=${common.PORT}`, script]);
(async function() {
try {
await t.test('validate debugger prompt and output', async () => {
await cli.waitForInitialBreak();
await cli.waitForPrompt();

assert.match(cli.output, /debug>/, 'prints a prompt');
assert.match(
cli.output,
new RegExp(`< Debugger listening on [^\n]*${common.PORT}`),
'forwards child output');
} finally {
'forwards child output'
);
});

await t.test('ensure CLI exits with code 0', async () => {
const code = await cli.quit();
assert.strictEqual(code, 0);
}
})().then(common.mustCall());
});
});
13 changes: 8 additions & 5 deletions test/sequential/test-worker-heapsnapshot-options.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');

require('../common');

const { recordState, getHeapSnapshotOptionTests } = require('../common/heap');
const { Worker } = require('worker_threads');
const { once } = require('events');
const { Worker } = require('node:worker_threads');
const { once } = require('node:events');
const { test } = require('node:test');

(async function() {
test('should handle heap snapshot options correctly in Worker threads', async () => {
const tests = getHeapSnapshotOptionTests();
const w = new Worker(tests.fixtures);

Expand All @@ -18,4 +21,4 @@ const { once } = require('events');
}

await w.terminate();
})().then(common.mustCall());
});

0 comments on commit c086664

Please sign in to comment.