I have successfully managed to execute Mocha tests in the browser using ES6 / Typescript with the following code:
// test.ts
import 'mocha/mocha.css';
import * as M from 'mocha/mocha-es2018';
import { expect } from 'chai';
M.setup('bdd');
// import more tests here
describe('test', () => {
it('test1', () => {
expect(true).to.true;
})
});
M.run();
After building the project (using vite), the html page loads properly. However, I want to include additional tests like this:
import './unit/sum.spec.ts';
// more imports
Unfortunately, adding these imports leads to the following error:
Uncaught ReferenceError: describe is not defined
Is there a way to make all Mocha functions globally accessible in an ES6 environment?