script: { "test": "jest --coverage" } ...}
2.2.3 添加jest.config.js:
注意testEnvironment设为 '...globals: { NODE_ENV: 'test', __wxConfig: { global: { window: {}, }, }, }, moduleNameMapper...$': 'ts-jest', }, preset: 'ts-jest', testEnvironment: 'jsdom', collectCoverage: true, coverageDirectory...coverageReporters: ['json-summary', 'text', 'lcov'], coveragePathIgnorePatterns: [ '/node_modules/', ], moduleNameMapper...(), set: jest.fn(), remove: jest.fn(),};jest.mock('..