Enable strict mode and bump target for test/smoke (#165296)

This commit is contained in:
Matt Bierner
2022-11-02 19:23:58 -07:00
committed by GitHub
parent c55ef92fed
commit f945df1b2d
3 changed files with 8 additions and 27 deletions

View File

@@ -71,18 +71,18 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
});
it('verifies that "hot exit" works for dirty files (without delay)', function () {
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_without_delay', undefined);
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_without_delay', undefined, undefined);
});
it('verifies that "hot exit" works for dirty files (with delay)', function () {
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_with_delay', 2000);
return testHotExit.call(this, 'test_verifies_that_hot_exit_works_for_dirty_files_with_delay', 2000, undefined);
});
it('verifies that auto save triggers on shutdown', function () {
return testHotExit.call(this, 'test_verifies_that_auto_save_triggers_on_shutdown', undefined, true);
});
async function testHotExit(title: string, restartDelay: number | undefined, autoSave: boolean | undefined) {
async function testHotExit(this: import('mocha').Context, title: string, restartDelay: number | undefined, autoSave: boolean | undefined) {
app = createApp({
...this.defaultOptions,
logsPath: suiteLogsPath(this.defaultOptions, title),
@@ -201,7 +201,7 @@ export function setup(ensureStableCode: () => string | undefined, logger: Logger
return testHotExit.call(this, `test_verifies_that_hot_exit_works_for_dirty_files_with_delay_from_stable`, 2000);
});
async function testHotExit(title: string, restartDelay: number | undefined) {
async function testHotExit(this: import('mocha').Context, title: string, restartDelay: number | undefined) {
const stableCodePath = ensureStableCode();
if (!stableCodePath) {
this.skip();

View File

@@ -19,25 +19,6 @@ export function itRepeat(n: number, description: string, callback: (this: Contex
}
}
/**
* Defines a test-case that will run but will be skips it if it throws an exception. This is useful
* to get some runs in CI when trying to stabilize a flaky test, without failing the build. Note
* that this only works if something inside the test throws, so a test's overall timeout won't work
* but throwing due to a polling timeout will.
* @param title The test-case title.
* @param callback The test-case callback.
*/
export function itSkipOnFail(title: string, callback: (this: Context) => any): void {
it(title, function () {
return Promise.resolve().then(() => {
return callback.apply(this, arguments);
}).catch(e => {
console.warn(`Test "${title}" failed but was marked as skip on fail:`, e);
this.skip();
});
});
}
export function installAllHandlers(logger: Logger, optionsTransform?: (opts: ApplicationOptions) => ApplicationOptions) {
installDiagnosticsHandler(logger);
installAppBeforeHandler(optionsTransform);
@@ -195,7 +176,7 @@ export async function retry<T>(task: ITask<Promise<T>>, delay: number, retries:
return await task();
} catch (error) {
lastError = error;
lastError = error as Error;
await timeout(delay);
}

View File

@@ -4,14 +4,14 @@
"noImplicitAny": false,
"removeComments": false,
"preserveConstEnums": true,
"target": "es2017",
"strictNullChecks": true,
"target": "es2020",
"strict": true,
"noUnusedParameters": false,
"noUnusedLocals": true,
"outDir": "out",
"sourceMap": true,
"lib": [
"es2016",
"es2020",
"dom"
]
},