Fix main.test.ts (#1320)

This commit is contained in:
Hood Chatham
2023-03-30 10:52:39 -07:00
committed by GitHub
parent 146afb6532
commit b61e8435d1
3 changed files with 12 additions and 13 deletions

View File

@@ -436,6 +436,10 @@ globalExport('pyscript_get_config', pyscript_get_config);
// main entry point of execution
const globalApp = new PyScriptApp();
globalApp.readyPromise = globalApp.main();
// This top level execution causes trouble in jest
if (typeof jest === 'undefined') {
globalApp.readyPromise = globalApp.main();
}
export { version };

View File

@@ -1,12 +1,7 @@
import { describe, it, expect } from '@jest/globals';
import { describe, it, beforeEach, expect } from '@jest/globals';
import { UserError, ErrorCode } from '../../src/exceptions';
import { PyScriptApp } from '../../src/main';
describe('Placeholder', () => {
it('this is a placeholder, we need to fix and re-enable the commented out tests', () => {
expect(true).toBe(true);
});
});
/*
describe('Test withUserErrorHandler', () => {
class MyApp extends PyScriptApp {
myRealMain: any;
@@ -17,7 +12,7 @@ describe('Test withUserErrorHandler', () => {
}
async _realMain() {
await this.myRealMain();
this.myRealMain();
}
}
@@ -68,8 +63,6 @@ describe('Test withUserErrorHandler', () => {
}
const app = new MyApp(myRealMain);
expect.assertions(1);
await expect(async () => await app.main()).resolves.toThrow(new Error('Explosions!'));
expect(app.main()).rejects.toThrow(new Error('Explosions!'));
});
});
*/

View File

@@ -4,3 +4,5 @@ import { directoryManifest } from '../../directoryManifest.mjs';
jest.unstable_mockModule('../../src/python_package', async () => ({
python_package: await directoryManifest('./src/python/'),
}));
globalThis.jest = jest;