forked from getodk/central-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (48 loc) · 1.93 KB
/
index.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sinon from 'sinon';
import { enableAutoUnmount } from '@vue/test-utils';
import { expect, should } from 'chai';
import '../src/styles';
import '../src/jquery';
import '../src/bootstrap';
import testData from './data';
import { loadAsyncRouteComponents } from './util/load-async';
import { mockLogin } from './util/session';
import { setupLanguages } from './util/i18n';
import './assertions';
window.beforeAll = before; // eslint-disable-line no-undef
window.afterAll = after; // eslint-disable-line no-undef
window.test = it;
window.should = should();
window.expect = expect;
////////////////////////////////////////////////////////////////////////////////
// HOOKS
// Even if a route is lazy-loaded, load() will need synchronous access to the
// async components associated with the route.
beforeAll(loadAsyncRouteComponents);
beforeEach(testData.seed);
enableAutoUnmount(afterEach);
afterEach(() => {
const app = document.querySelector('[data-v-app]');
if (app != null) app.parentNode.removeChild(app);
const afterScript = document.querySelector('body > script:last-of-type + *');
if (afterScript != null) {
console.error(document.body.innerHTML); // eslint-disable-line no-console
throw new Error('Unexpected element after last script element. Have all Bootstrap elements been removed?');
}
});
afterEach(() => {
sinon.restore();
document.documentElement.setAttribute('lang', 'en');
localStorage.clear();
testData.reset();
mockLogin.reset();
});
setupLanguages(afterEach);
////////////////////////////////////////////////////////////////////////////////
// RUN TESTS
// Run all tests. See the documentation for karma-webpack. We specify the files
// here rather than in karma.conf.js, because doing so is more performant. When
// I tried specifying the tests in karma.conf.js, I encountered an out-of-memory
// error.
const testsContext = require.context('.', true, /\.spec\.js$/);
testsContext.keys().forEach(testsContext);