mirror of https://github.com/keeweb/keeweb.git
better tests compatibility
This commit is contained in:
parent
f840f7b15d
commit
6f068ebf18
|
@ -42,7 +42,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
bootstrap().catch(noop);
|
||||
});
|
||||
|
||||
async function bootstrap() {
|
||||
export async function bootstrap(): Promise<void> {
|
||||
StartProfiler.milestone('document ready');
|
||||
|
||||
const logger = new Logger('bootstrap');
|
||||
|
|
|
@ -19,10 +19,10 @@ interface Baron {
|
|||
dispose(): void;
|
||||
}
|
||||
|
||||
const module = require('baron') as {
|
||||
const mod = require('baron') as {
|
||||
default: (params: BaronParams) => Baron;
|
||||
};
|
||||
|
||||
const baron = module.default;
|
||||
const baron = mod.default;
|
||||
|
||||
export { baron };
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"start": "grunt",
|
||||
"test": "mocha --require ts-node/register --require tsconfig-paths/register --require test/init.ts --recursive --reporter spec 'test/**/*.spec.ts'",
|
||||
"test": "mocha --require ts-node/register,tsconfig-paths/register,test/init.ts --recursive --reporter spec 'test/**/*.spec.ts'",
|
||||
"eslint": "grunt eslint",
|
||||
"build-beta": "grunt --beta && cp dist/index.html ../keeweb-beta/index.html && cd ../keeweb-beta && git add index.html && git commit -a -m 'beta' && git push origin master",
|
||||
"electron": "cross-env KEEWEB_IS_PORTABLE=0 ELECTRON_DISABLE_SECURITY_WARNINGS=1 KEEWEB_EMULATE_HARDWARE_ENCRYPTION=persistent KEEWEB_HTML_PATH=http://localhost:8085 electron desktop --no-sandbox",
|
||||
|
|
19
test/init.ts
19
test/init.ts
|
@ -21,6 +21,9 @@ global.navigator = jsdom.navigator;
|
|||
global.screen = jsdom.screen;
|
||||
global.location = jsdom.location;
|
||||
global.document = jsdom.document;
|
||||
global.requestAnimationFrame = setTimeout;
|
||||
global.HTMLElement = jsdom.HTMLElement;
|
||||
global.customElements = jsdom.customElements;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
global.window = jsdom.window;
|
||||
|
@ -52,9 +55,23 @@ function requireTextFile(filePath: string): () => { default: string } {
|
|||
};
|
||||
}
|
||||
|
||||
function requireBase64File(filePath: string): () => string {
|
||||
return () => {
|
||||
filePath = path.resolve(__dirname, '..', filePath);
|
||||
return fs.readFileSync(filePath, 'base64');
|
||||
};
|
||||
}
|
||||
|
||||
const knownModules: Record<string, any> = {
|
||||
'demo.kdbx': requireBase64File('app/resources/demo.kdbx'),
|
||||
'public-key.pem': requireTextFile('app/resources/public-key.pem'),
|
||||
'public-key-new.pem': requireTextFile('app/resources/public-key-new.pem')
|
||||
'public-key-new.pem': requireTextFile('app/resources/public-key-new.pem'),
|
||||
'!!raw-loader!../../styles/base/_theme-vars.scss': requireTextFile(
|
||||
'app/styles/base/_theme-vars.scss'
|
||||
),
|
||||
'!!raw-loader!../../styles/themes/_theme-defaults.scss': requireTextFile(
|
||||
'app/styles/themes/_theme-defaults.scss'
|
||||
)
|
||||
};
|
||||
|
||||
const originalRequire = Module.prototype.require;
|
||||
|
|
Loading…
Reference in New Issue