【发布时间】:2021-11-17 02:45:58
【问题描述】:
我正在使用Tone.js 在Typescript 中创建一个应用程序,并且我正在使用Jest 对其进行测试。
我有一个Musician 类:
import * as Tone from 'tone';
export class Musician {
instrument: Tone.Synth;
constructor() {
this.instrument = new Tone.Synth().toDestination();
}
}
这是我测试它的地方:
import { Musician } from '../src/musician';
test("Musician has an instrument", () => {
const musician = new Musician();
expect(musician.instrument).toBeDefined();
});
当我运行这个测试时,我得到了这个:。
这是我的tsconfig.json:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
这是我的jest.config.js:
module.exports = {
preset: "ts-jest",
testEnvironment: "jsdom",
};
【问题讨论】:
标签: typescript jestjs ts-jest tone.js