Skip to content

Commit 28d9484

Browse files
SeptiasSeptias
andauthored
fix(node): run tests with native ESM modules instead of esm (#5194)
close #5156 --------- Co-authored-by: Septias <scoreplayer2000@gmail.comclear>
1 parent e67e684 commit 28d9484

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

node/lib/deltachat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export class AccountManager extends EventEmitter {
178178
static newTemporary() {
179179
let directory = null
180180
while (true) {
181-
const randomString = Math.random().toString(36).substr(2, 5)
181+
const randomString = Math.random().toString(36).substring(2, 5)
182182
directory = join(tmpdir(), 'deltachat-' + randomString)
183183
if (!existsSync(directory)) break
184184
}

node/test/test.js renamed to node/test/test.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// @ts-check
2-
import DeltaChat from '../dist'
2+
import { DeltaChat } from '../dist/index.js'
33

44
import { deepStrictEqual, strictEqual } from 'assert'
55
import chai, { expect } from 'chai'
66
import chaiAsPromised from 'chai-as-promised'
7-
import { EventId2EventName, C } from '../dist/constants'
7+
import { EventId2EventName, C } from '../dist/constants.js'
88
import { join } from 'path'
99
import { statSync } from 'fs'
10-
import { Context } from '../dist/context'
10+
import { Context } from '../dist/context.js'
11+
import {fileURLToPath} from 'url';
12+
13+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
14+
1115
chai.use(chaiAsPromised)
1216
chai.config.truncateThreshold = 0 // Do not truncate assertion errors.
1317

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"@types/node": "^20.8.10",
1111
"chai": "~4.3.10",
1212
"chai-as-promised": "^7.1.1",
13-
"esm": "^3.2.25",
1413
"mocha": "^8.2.1",
1514
"node-gyp": "^10.0.0",
1615
"prebuildify": "^5.0.1",
@@ -53,7 +52,7 @@
5352
"prebuildify": "cd node && prebuildify -t 18.0.0 --napi --strip --postinstall \"node scripts/postinstall.js --prebuild\"",
5453
"test": "npm run test:lint && npm run test:mocha",
5554
"test:lint": "npm run lint",
56-
"test:mocha": "mocha -r esm node/test/test.js --growl --reporter=spec --bail --exit"
55+
"test:mocha": "mocha node/test/test.mjs --growl --reporter=spec --bail --exit"
5756
},
5857
"types": "node/dist/index.d.ts",
5958
"version": "1.133.0"

0 commit comments

Comments
 (0)