mirror of
https://github.com/foambubble/foam.git
synced 2026-01-10 06:28:12 -05:00
Fixed test suite
* tweaking error propagation * updated xvfb-action version * improved logging * only adding actually failing tests to failures (no comment)
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -58,6 +58,6 @@ jobs:
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
- name: Run Tests
|
||||
uses: GabrielBB/xvfb-action@v1.0
|
||||
uses: GabrielBB/xvfb-action@v1.4
|
||||
with:
|
||||
run: yarn test
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('Foam URIs', () => {
|
||||
'../relative/file.md#section',
|
||||
URI.parse('file:/path/relative/file.md#section'),
|
||||
],
|
||||
])('URI Parsing (%s) - %s', (input, exp) => {
|
||||
])('URI Parsing (%s)', (input, exp) => {
|
||||
const result = URI.resolve(input, base);
|
||||
expect(result.scheme).toEqual(exp.scheme);
|
||||
expect(result.authority).toEqual(exp.authority);
|
||||
|
||||
@@ -14,20 +14,26 @@ function parseArgs(): { unit: boolean; e2e: boolean } {
|
||||
async function main() {
|
||||
const { unit, e2e } = parseArgs();
|
||||
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
||||
let isSuccess = true;
|
||||
|
||||
// The path to the extension test script
|
||||
// Passed to --extensionTestsPath
|
||||
if (unit) {
|
||||
if (unit) {
|
||||
try {
|
||||
console.log('Running unit tests');
|
||||
await runUnit();
|
||||
} catch (err) {
|
||||
console.error('Error occurred while running Foam unit tests:', err);
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (e2e) {
|
||||
if (e2e) {
|
||||
try {
|
||||
console.log('Running e2e tests');
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
||||
// The path to the extension test script
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './suite');
|
||||
const tmpWorkspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'foam-'));
|
||||
|
||||
@@ -36,16 +42,20 @@ async function main() {
|
||||
extensionDevelopmentPath,
|
||||
extensionTestsPath,
|
||||
launchArgs: [tmpWorkspaceDir, '--disable-extensions'],
|
||||
// Running the tests with vscode 1.53.0 is causing issues in `suite.ts:23`,
|
||||
// Running the tests with vscode 1.53.0 is causing issues in the output/error stream management,
|
||||
// which is causing a stack overflow, possibly due to a recursive callback.
|
||||
// Also see https://github.com/foambubble/foam/pull/479#issuecomment-774167127
|
||||
// Forcing the version to 1.52.0 solves the problem.
|
||||
// TODO: to review, further investigate, and roll back this workaround.
|
||||
version: '1.52.0',
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error occurred while running Foam e2e tests:', err);
|
||||
isSuccess = false;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests');
|
||||
}
|
||||
|
||||
if (!isSuccess) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ export function run(): Promise<void> {
|
||||
const errWrite = process.stderr.write;
|
||||
process.stdout.write = bufferLinesAndLog(console.log.bind(console));
|
||||
process.stderr.write = bufferLinesAndLog(console.error.bind(console));
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
// process.on('unhandledRejection', err => {
|
||||
// throw err;
|
||||
// });
|
||||
process.env.FORCE_COLOR = '1';
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.BABEL_ENV = 'test';
|
||||
@@ -61,7 +61,7 @@ export function run(): Promise<void> {
|
||||
tsconfig: path.resolve(rootDir, './tsconfig.json'),
|
||||
},
|
||||
}),
|
||||
testTimeout: 20000,
|
||||
testTimeout: 30000,
|
||||
verbose: true,
|
||||
colors: true,
|
||||
} as any,
|
||||
@@ -69,7 +69,9 @@ export function run(): Promise<void> {
|
||||
);
|
||||
|
||||
const failures = results.testResults.reduce((acc, res) => {
|
||||
acc.push(res as any);
|
||||
if (res.failureMessage) {
|
||||
acc.push(res as any);
|
||||
}
|
||||
return acc;
|
||||
}, [] as jest.TestResult[]);
|
||||
|
||||
@@ -77,10 +79,14 @@ export function run(): Promise<void> {
|
||||
console.log(r);
|
||||
});
|
||||
|
||||
return failures.length === 0
|
||||
? resolve()
|
||||
: reject(`${JSON.stringify(failures)}`);
|
||||
if (failures.length > 0) {
|
||||
console.error('Some Foam tests failed: ', failures.length);
|
||||
reject(`${JSON.stringify(failures)}`);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('There was an error while running the Foam suite', error);
|
||||
return reject(error);
|
||||
} finally {
|
||||
process.stdout.write = outWrite.bind(process.stdout);
|
||||
|
||||
Reference in New Issue
Block a user