mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Tests: Fail test units when an uncaught exception is thrown inside asyncTest
This commit is contained in:
parent
cc7e2fc456
commit
f3e9668eb7
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
require('app-module-path').addPath(__dirname);
|
require('app-module-path').addPath(__dirname);
|
||||||
|
|
||||||
const { extractExecutablePath, quotePath, unquotePath, friendlySafeFilename, toFileProtocolPath} = require('lib/path-utils.js');
|
const { extractExecutablePath, quotePath, unquotePath, friendlySafeFilename, toFileProtocolPath } = require('lib/path-utils.js');
|
||||||
const { fileContentEqual, setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync } = require('test-utils.js');
|
const { asyncTest, fileContentEqual, setupDatabase, setupDatabaseAndSynchronizer, db, synchronizer, fileApi, sleep, clearDatabase, switchClient, syncTargetId, objectsEqual, checkThrowAsync } = require('test-utils.js');
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, p) => {
|
process.on('unhandledRejection', (reason, p) => {
|
||||||
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
|
||||||
@ -15,7 +15,7 @@ describe('pathUtils', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create friendly safe filename', async (done) => {
|
it('should create friendly safe filename', asyncTest(async () => {
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['生活', '生活'],
|
['生活', '生活'],
|
||||||
['not/good', 'not_good'],
|
['not/good', 'not_good'],
|
||||||
@ -34,11 +34,9 @@ describe('pathUtils', function() {
|
|||||||
|
|
||||||
expect(!!friendlySafeFilename('')).toBe(true);
|
expect(!!friendlySafeFilename('')).toBe(true);
|
||||||
expect(!!friendlySafeFilename('...')).toBe(true);
|
expect(!!friendlySafeFilename('...')).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
done();
|
it('should quote and unquote paths', asyncTest(async () => {
|
||||||
});
|
|
||||||
|
|
||||||
it('should quote and unquote paths', async (done) => {
|
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['', ''],
|
['', ''],
|
||||||
['/my/path', '/my/path'],
|
['/my/path', '/my/path'],
|
||||||
@ -53,11 +51,9 @@ describe('pathUtils', function() {
|
|||||||
expect(quotePath(t[0])).toBe(t[1]);
|
expect(quotePath(t[0])).toBe(t[1]);
|
||||||
expect(unquotePath(quotePath(t[0]))).toBe(t[0]);
|
expect(unquotePath(quotePath(t[0]))).toBe(t[0]);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
done();
|
it('should extract executable path from command', asyncTest(async () => {
|
||||||
});
|
|
||||||
|
|
||||||
it('should extract executable path from command', async (done) => {
|
|
||||||
const testCases = [
|
const testCases = [
|
||||||
['', ''],
|
['', ''],
|
||||||
['/my/cmd -some -args', '/my/cmd'],
|
['/my/cmd -some -args', '/my/cmd'],
|
||||||
@ -71,11 +67,9 @@ describe('pathUtils', function() {
|
|||||||
const t = testCases[i];
|
const t = testCases[i];
|
||||||
expect(extractExecutablePath(t[0])).toBe(t[1]);
|
expect(extractExecutablePath(t[0])).toBe(t[1]);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
done();
|
it('should create correct fileURL syntax', asyncTest(async () => {
|
||||||
});
|
|
||||||
|
|
||||||
it('should create correct fileURL syntax', async (done) => {
|
|
||||||
const testCases_win32 = [
|
const testCases_win32 = [
|
||||||
['C:\\handle\\space test', 'file:///C:/handle/space+test'],
|
['C:\\handle\\space test', 'file:///C:/handle/space+test'],
|
||||||
['C:\\escapeplus\\+', 'file:///C:/escapeplus/%2B'],
|
['C:\\escapeplus\\+', 'file:///C:/escapeplus/%2B'],
|
||||||
@ -95,8 +89,6 @@ describe('pathUtils', function() {
|
|||||||
const t = testCases_unixlike[i];
|
const t = testCases_unixlike[i];
|
||||||
expect(toFileProtocolPath(t[0], 'linux')).toBe(t[1]);
|
expect(toFileProtocolPath(t[0], 'linux')).toBe(t[1]);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -357,6 +357,7 @@ function asyncTest(callback) {
|
|||||||
await callback();
|
await callback();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
expect('good').toBe('not good', 'Test has thrown an exception - see above error');
|
||||||
} finally {
|
} finally {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,35 @@
|
|||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/node_modules/": true,
|
|
||||||
"_mydocs/mdtest/": true,
|
"_mydocs/mdtest/": true,
|
||||||
|
"_releases/": true,
|
||||||
"_vieux/": true,
|
"_vieux/": true,
|
||||||
"ElectronClient/app/fonts/": true,
|
"*.sublime-workspace": true,
|
||||||
|
"**/_mydocs/EnexSamples/*.enex": true,
|
||||||
|
"**/*.base64": true,
|
||||||
|
"**/*.bundle.js": true,
|
||||||
|
"**/*.icns": true,
|
||||||
|
"**/*.jar": true,
|
||||||
|
"**/*.map": true,
|
||||||
|
"**/*.min.css": true,
|
||||||
|
"**/*.min.js": true,
|
||||||
|
"**/*.po": true,
|
||||||
|
"**/*.po~": true,
|
||||||
|
"**/*.pot": true,
|
||||||
|
"**/CliClient/app/lib": true,
|
||||||
|
"**/CliClient/app/src": true,
|
||||||
|
"**/docs/*.html": true,
|
||||||
|
"**/docs/*.svg": true,
|
||||||
|
"**/ElectronClient/app/css/font-awesome.min.css": true,
|
||||||
|
"**/ElectronClient/app/gui/note-viewer/highlight/*.pack.js": true,
|
||||||
|
"**/locales/*.json": true,
|
||||||
|
"**/log.txt": true,
|
||||||
|
"**/node_modules/": true,
|
||||||
|
"**/package-lock.json": true,
|
||||||
|
"**/ReactNativeClient/lib/mime-utils.js": true,
|
||||||
|
"**/ReactNativeClient/locales/*": true,
|
||||||
|
"**/src/log.txt": true,
|
||||||
|
"**/yarn.lock": true,
|
||||||
"CliClient/app/lib/": true,
|
"CliClient/app/lib/": true,
|
||||||
"CliClient/app/src/": true,
|
"CliClient/app/src/": true,
|
||||||
"CliClient/build/": true,
|
"CliClient/build/": true,
|
||||||
@ -20,50 +45,28 @@
|
|||||||
"CliClient/tests/fuzzing/": true,
|
"CliClient/tests/fuzzing/": true,
|
||||||
"CliClient/tests/src/": true,
|
"CliClient/tests/src/": true,
|
||||||
"CliClient/tests/sync/": true,
|
"CliClient/tests/sync/": true,
|
||||||
"ElectronClient/dist/": true,
|
"Clipper/joplin-webclipper/dist/": true,
|
||||||
"ElectronClient/build/": true,
|
"Clipper/joplin-webclipper/popup/build/": true,
|
||||||
|
"ElectronClient/app/dist/": true,
|
||||||
|
"ElectronClient/app/fonts/": true,
|
||||||
|
"ElectronClient/app/gui/note-viewer/highlight/styles/": true,
|
||||||
"ElectronClient/app/lib/": true,
|
"ElectronClient/app/lib/": true,
|
||||||
"ElectronClient/app/locale/": true,
|
"ElectronClient/app/locale/": true,
|
||||||
|
"ElectronClient/build/": true,
|
||||||
|
"ElectronClient/dist/": true,
|
||||||
"node_modules/": true,
|
"node_modules/": true,
|
||||||
"ReactNativeClient/android/.gradle/": true,
|
"ReactNativeClient/android/.gradle/": true,
|
||||||
"ReactNativeClient/android/.idea/": true,
|
"ReactNativeClient/android/.idea/": true,
|
||||||
"ReactNativeClient/android/app/build/": true,
|
"ReactNativeClient/android/app/build/": true,
|
||||||
"ReactNativeClient/android/build/": true,
|
"ReactNativeClient/android/build/": true,
|
||||||
"ReactNativeClient/android/local.properties/": true,
|
"ReactNativeClient/android/local.properties/": true,
|
||||||
"ReactNativeClient/node_modules/": true,
|
|
||||||
"ElectronClient/app/gui/note-viewer/highlight/styles/": true,
|
|
||||||
"tests/logs/": true,
|
|
||||||
"ReactNativeClient/ios/build/": true,
|
"ReactNativeClient/ios/build/": true,
|
||||||
"ElectronClient/app/dist/": true,
|
|
||||||
"_releases/": true,
|
|
||||||
"ReactNativeClient/lib/csstojs/": true,
|
"ReactNativeClient/lib/csstojs/": true,
|
||||||
"Clipper/joplin-webclipper/popup/build/": true,
|
|
||||||
"Clipper/joplin-webclipper/dist/": true,
|
|
||||||
"ReactNativeClient/lib/rnInjectedJs/": true,
|
"ReactNativeClient/lib/rnInjectedJs/": true,
|
||||||
"**/*.jar": true,
|
"ReactNativeClient/node_modules/": true,
|
||||||
"**/*.map": true,
|
"Server/db*.sqlite/": true,
|
||||||
"**/*.po": true,
|
"Server/dist/": true,
|
||||||
"**/*.po~": true,
|
"tests/logs/": true,
|
||||||
"**/*.pot": true,
|
|
||||||
"**/CliClient/app/lib": true,
|
|
||||||
"**/CliClient/app/src": true,
|
|
||||||
"**/locales/*.json": true,
|
|
||||||
"**/log.txt": true,
|
|
||||||
"**/package-lock.json": true,
|
|
||||||
"**/ReactNativeClient/locales/*": true,
|
|
||||||
"**/src/log.txt": true,
|
|
||||||
"**/ElectronClient/app/gui/note-viewer/highlight/*.pack.js": true,
|
|
||||||
"**/ElectronClient/app/css/font-awesome.min.css": true,
|
|
||||||
"**/docs/*.html": true,
|
|
||||||
"**/docs/*.svg": true,
|
|
||||||
"**/ReactNativeClient/lib/mime-utils.js": true,
|
|
||||||
"**/_mydocs/EnexSamples/*.enex": true,
|
|
||||||
"**/*.min.css": true,
|
|
||||||
"**/*.min.js": true,
|
|
||||||
"**/*.bundle.js": true,
|
|
||||||
"**/yarn.lock": true,
|
|
||||||
"**/*.icns": true,
|
|
||||||
"**/*.base64": true,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user