mirror of
https://github.com/flarum/framework.git
synced 2025-06-26 13:11:23 +08:00
feat(jest): create jest config package for unit testing (#3678)
* feat(jest): create jest config package for unit testing * chore: housekeeping * fix: now we need to explicitly allow importing without extension * fix: recover EditorDriverInterface import * Apply suggestions from code review * chore: yarn Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
39
js-packages/jest-config/setup-env.js
Normal file
39
js-packages/jest-config/setup-env.js
Normal file
@ -0,0 +1,39 @@
|
||||
import app from '@flarum/core/src/forum/app';
|
||||
import ForumApplication from '@flarum/core/src/forum/ForumApplication';
|
||||
import jsYaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import jquery from 'jquery';
|
||||
import m from 'mithril';
|
||||
import flatten from 'flat';
|
||||
|
||||
// Boot the Flarum app.
|
||||
function bootApp() {
|
||||
ForumApplication.prototype.mount = () => {};
|
||||
window.flarum = { extensions: {} };
|
||||
app.load({
|
||||
apiDocument: null,
|
||||
locale: 'en',
|
||||
locales: {},
|
||||
resources: [
|
||||
{
|
||||
type: 'forums',
|
||||
id: '1',
|
||||
attributes: {},
|
||||
},
|
||||
],
|
||||
session: {
|
||||
userId: 0,
|
||||
csrfToken: 'test',
|
||||
},
|
||||
});
|
||||
app.translator.addTranslations(flatten(jsYaml.load(fs.readFileSync('../locale/core.yml', 'utf8'))));
|
||||
app.bootExtensions(window.flarum.extensions);
|
||||
app.boot();
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
window.$ = jquery;
|
||||
window.m = m;
|
||||
|
||||
bootApp();
|
||||
});
|
Reference in New Issue
Block a user