GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: reduce flakiness of `test-assert-esm-cjs-message-verify` · nodejs/node@5cea7ed

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-assert-esm-cjs-message-verify.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-assert-esm-cjs-message-verify.js‎

Copy file name to clipboard
+12-32Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,31 @@
11
'use strict';
22

33
const { spawnPromisified } = require('../common');
4-
const tmpdir = require('../common/tmpdir');
5-
const assert = require('assert');
6-
const { writeFileSync, unlink } = require('fs');
7-
const { describe, after, it } = require('node:test');
8-
9-
tmpdir.refresh();
4+
const assert = require('node:assert');
5+
const { describe, it } = require('node:test');
106

117
const fileImports = {
12-
cjs: 'const assert = require("assert");',
13-
mjs: 'import assert from "assert";',
8+
commonjs: 'const assert = require("assert");',
9+
module: 'import assert from "assert";',
1410
};
1511

16-
const fileNames = [];
17-
18-
for (const [ext, header] of Object.entries(fileImports)) {
19-
const fileName = `test-file.${ext}`;
20-
// Store the generated filesnames in an array
21-
fileNames.push(`${tmpdir.path}/${fileName}`);
22-
23-
writeFileSync(tmpdir.resolve(fileName), `${header}\nassert.ok(0 === 2);`);
24-
}
25-
2612
describe('ensure the assert.ok throwing similar error messages for esm and cjs files', () => {
27-
const nodejsPath = `${process.execPath}`;
28-
const errorsMessages = [];
29-
3013
it('should return code 1 for each command', async () => {
31-
for (const fileName of fileNames) {
32-
const { stderr, code } = await spawnPromisified(nodejsPath, [fileName]);
14+
const errorsMessages = [];
15+
for (const [inputType, header] of Object.entries(fileImports)) {
16+
const { stderr, code } = await spawnPromisified(process.execPath, [
17+
'--input-type',
18+
inputType,
19+
'--eval',
20+
`${header}\nassert.ok(0 === 2);\n`,
21+
]);
3322
assert.strictEqual(code, 1);
3423
// For each error message, filter the lines which will starts with AssertionError
3524
errorsMessages.push(
3625
stderr.split('\n').find((s) => s.startsWith('AssertionError'))
3726
);
3827
}
39-
});
40-
41-
after(() => {
4228
assert.strictEqual(errorsMessages.length, 2);
4329
assert.deepStrictEqual(errorsMessages[0], errorsMessages[1]);
44-
45-
for (const fileName of fileNames) {
46-
unlink(fileName, () => {});
47-
}
48-
49-
tmpdir.refresh();
5030
});
5131
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.