Skip to content

Commit ebd4f9e

Browse files
authored
chore: Replaced vitest (#44)
1 parent e864993 commit ebd4f9e

9 files changed

Lines changed: 20 additions & 20 deletions

File tree

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
"scripts": {
1919
"lint": "eslint .",
2020
"lint:fix": "eslint --fix .",
21-
"test": "vitest run",
22-
"test:watch": "vitest"
21+
"test": "node --test tests/tests.test.mjs",
22+
"test:watch": "node --watch --test tests/tests.test.mjs"
2323
},
2424
"devDependencies": {
2525
"@types/node": "^18.0.0",
2626
"eslint": "^9.39.4",
2727
"neostandard": "^0.13.0",
28-
"typescript": "^5.8.3",
29-
"vitest": "^2.1.8"
28+
"typescript": "^5.8.3"
3029
},
3130
"volta": {
3231
"node": "22.15.0"

tests/arguments_mutation/mod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
33
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
44
**/
5-
const assert = require('assert');
5+
const assert = require('node:assert');
66

77
function fetch_simple (url, cb) {
88
assert.strictEqual(this.this, 'this');

tests/arguments_mutation/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
44
**/
55
const { fetch_simple, fetch_complex } = require('./instrumented.js');
6-
const assert = require('assert');
7-
const { tracingChannel } = require('diagnostics_channel');
6+
const assert = require('node:assert');
7+
const { tracingChannel } = require('node:diagnostics_channel');
88

99
const handler = {
1010
start (message) {

tests/common/preamble.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
33
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
44
**/
5-
const { tracingChannel } = require('diagnostics_channel');
6-
const assert = require('assert');
5+
const { tracingChannel } = require('node:diagnostics_channel');
6+
const assert = require('node:assert');
77
function getContext (channelName) {
88
const channel = tracingChannel(channelName);
99
const context = {};

tests/custom_transform_cjs/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { fetch } = require('./instrumented.js');
2-
const assert = require('assert');
2+
const assert = require('node:assert');
33

44
fetch('https://example.com');
55
assert.strictEqual(global.__customCalled, true);

tests/polyfill_cjs/polyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
33
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
44
**/
5-
module.exports = require('diagnostics_channel');
5+
module.exports = require('node:diagnostics_channel');
66
const tracingChannel = module.exports.tracingChannel;
77
tracingChannel.polyfilled = true;
88
module.exports.tracingChannel = tracingChannel;

tests/polyfill_cjs/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**/
55
const { fetch } = require('./instrumented.js');
66
const { assert, getContext } = require('../common/preamble.js');
7-
const { tracingChannel } = require('diagnostics_channel');
7+
const { tracingChannel } = require('node:diagnostics_channel');
88
const context = getContext('orchestrion:undici:fetch_decl');
99
(async () => {
1010
const result = await fetch('https://example.com');

tests/polyfill_mjs/polyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
33
* This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2025 Datadog, Inc.
44
**/
5-
const dc = require('diagnostics_channel')
5+
const dc = require('node:diagnostics_channel')
66
const api = {}
77
api.tracingChannel = dc.tracingChannel
88
api.tracingChannel.polyfilled = true

tests/tests.test.mjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { create } from '../lib/index.js'
2-
import { describe, test, expect } from 'vitest'
2+
import { describe, test } from 'node:test'
3+
import assert from 'node:assert'
34
import { readFileSync, writeFileSync, rmSync, existsSync } from 'node:fs'
45
import { spawnSync } from 'node:child_process'
56
import { join, dirname } from 'node:path'
@@ -43,7 +44,7 @@ function runTest (testName, configs, { mjs = false, filePath = TEST_MODULE_PATH,
4344
const output = (result.stdout?.toString() || '') + (result.stderr?.toString() || '')
4445
throw new Error(`node test.${ext} exited with ${result.status}:\n${output}`)
4546
}
46-
expect(result.status).toBe(0)
47+
assert.equal(result.status, 0)
4748
}
4849

4950
describe('arguments_mutation', () => {
@@ -461,7 +462,7 @@ describe('buffer_input', () => {
461462
const fromString = transformer.transform(code, 'cjs')
462463
const fromBuffer = transformer.transform(Buffer.from(code), 'cjs')
463464

464-
expect(fromBuffer.code).toBe(fromString.code)
465+
assert.equal(fromBuffer.code, fromString.code)
465466
})
466467
})
467468

@@ -488,20 +489,20 @@ describe('source_map', () => {
488489
const transformer = instrumentor.getTransformer(TEST_MODULE_NAME, TEST_MODULE_VERSION, TEST_MODULE_PATH)
489490
const { code: generatedCode, map } = transformer.transform(originalCode, 'cjs')
490491

491-
expect(map).toBeTruthy()
492+
assert.ok(map)
492493

493494
const consumer = new SourceMapConsumer(JSON.parse(map))
494495
const generatedLines = generatedCode.split('\n')
495496

496497
// Find the generated line containing `return 42` and the column of `42`
497498
const generatedLine = generatedLines.findIndex(l => l.includes('return 42')) + 1
498-
expect(generatedLine).toBeGreaterThan(0)
499+
assert.equal(generatedLine > 0, true)
499500
const generatedColumn = generatedLines[generatedLine - 1].indexOf('42')
500501

501502
const original = consumer.originalPositionFor({ line: generatedLine, column: generatedColumn })
502503

503-
expect(original.line).toBe(originalReturnLine)
504-
expect(original.column).toBe(originalReturnColumn)
504+
assert.equal(original.line, originalReturnLine)
505+
assert.equal(original.column, originalReturnColumn)
505506
})
506507
})
507508

0 commit comments

Comments
 (0)