- Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathindex.ts
30 lines (26 loc) · 683 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// imports mocha for the browser, defining the `mocha` global.
require('mocha/mocha');
exportfunctionrun(): Promise<void>{
returnnewPromise((c,e)=>{
mocha.setup({
ui: 'tdd',
reporter: undefined
});
// bundles all files in the current directory matching `*.test`
constimportAll=(r: __WebpackModuleApi.RequireContext)=>r.keys().forEach(r);
importAll(require.context('.',true,/\.test$/));
try{
// Run the mocha test
mocha.run(failures=>{
if(failures>0){
e(newError(`${failures} tests failed.`));
}else{
c();
}
});
}catch(err){
console.error(err);
e(err);
}
});
}