diff --git a/node/lib/deltachat.ts b/node/lib/deltachat.ts index dbf002e46..6080aacda 100644 --- a/node/lib/deltachat.ts +++ b/node/lib/deltachat.ts @@ -178,7 +178,7 @@ export class AccountManager extends EventEmitter { static newTemporary() { let directory = null while (true) { - const randomString = Math.random().toString(36).substr(2, 5) + const randomString = Math.random().toString(36).substring(2, 5) directory = join(tmpdir(), 'deltachat-' + randomString) if (!existsSync(directory)) break } diff --git a/node/test/test.js b/node/test/test.mjs similarity index 99% rename from node/test/test.js rename to node/test/test.mjs index d8f729071..7bef6d21c 100644 --- a/node/test/test.js +++ b/node/test/test.mjs @@ -1,13 +1,17 @@ // @ts-check -import DeltaChat from '../dist' +import { DeltaChat } from '../dist/index.js' import { deepStrictEqual, strictEqual } from 'assert' import chai, { expect } from 'chai' import chaiAsPromised from 'chai-as-promised' -import { EventId2EventName, C } from '../dist/constants' +import { EventId2EventName, C } from '../dist/constants.js' import { join } from 'path' import { statSync } from 'fs' -import { Context } from '../dist/context' +import { Context } from '../dist/context.js' +import {fileURLToPath} from 'url'; + +const __dirname = fileURLToPath(new URL('.', import.meta.url)); + chai.use(chaiAsPromised) chai.config.truncateThreshold = 0 // Do not truncate assertion errors. diff --git a/package.json b/package.json index 5f209a190..bac045d6b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "@types/node": "^20.8.10", "chai": "~4.3.10", "chai-as-promised": "^7.1.1", - "esm": "^3.2.25", "mocha": "^8.2.1", "node-gyp": "^10.0.0", "prebuildify": "^5.0.1", @@ -53,7 +52,7 @@ "prebuildify": "cd node && prebuildify -t 18.0.0 --napi --strip --postinstall \"node scripts/postinstall.js --prebuild\"", "test": "npm run test:lint && npm run test:mocha", "test:lint": "npm run lint", - "test:mocha": "mocha -r esm node/test/test.js --growl --reporter=spec --bail --exit" + "test:mocha": "mocha node/test/test.mjs --growl --reporter=spec --bail --exit" }, "types": "node/dist/index.d.ts", "version": "1.133.0"