Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid returning failureMessages: [undefined] #76

Merged
merged 3 commits into from May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions jest.config.js
@@ -1,9 +1,5 @@
module.exports = {
projects: [
{
displayName: 'e2e',
testMatch: ['<rootDir>/e2e/*.test.ts'],
},
],
reporters: ['default', 'github-actions'],
testMatch: ['<rootDir>/**/__tests__/*.test.ts', '<rootDir>/e2e/*.test.ts'],
testTimeout: 30000,
};
55 changes: 55 additions & 0 deletions src/__tests__/__snapshots__/fail.test.ts.snap
@@ -0,0 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`fails 1`] = `
Object {
"console": null,
"failureMessage": " ● tsd typecheck

Argument of type 'number' is not assignable to parameter of type 'string'.

> 5 | expectType<string>(concat(1, 2));
| ^

at e2e/__fixtures__/js-failing/index.test.ts:5:1",
"numFailingTests": 1,
"numPassingTests": 3,
"numPendingTests": 0,
"numTodoTests": 0,
"perfStats": Object {
"end": 1200,
"start": 0,
},
"skipped": undefined,
"snapshot": Object {
"added": 0,
"fileDeleted": false,
"matched": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0,
},
"sourceMaps": Object {},
"testExecError": null,
"testFilePath": "/path/to/e2e/__fixtures__/js-failing/index.test.ts",
"testResults": Array [
Object {
"ancestorTitles": Array [],
"duration": 1200,
"failureMessages": Array [
" ● tsd typecheck

Argument of type 'number' is not assignable to parameter of type 'string'.

> 5 | expectType<string>(concat(1, 2));
| ^

at e2e/__fixtures__/js-failing/index.test.ts:5:1",
],
"fullName": undefined,
"numPassingAsserts": 1,
"status": "failed",
"title": "tsd typecheck",
},
],
}
`;
39 changes: 39 additions & 0 deletions src/__tests__/__snapshots__/pass.test.ts.snap
@@ -0,0 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`pass 1`] = `
Object {
"console": null,
"failureMessage": undefined,
"numFailingTests": 0,
"numPassingTests": 5,
"numPendingTests": 0,
"numTodoTests": 0,
"perfStats": Object {
"end": 1200,
"start": 0,
},
"skipped": undefined,
"snapshot": Object {
"added": 0,
"fileDeleted": false,
"matched": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0,
},
"sourceMaps": Object {},
"testExecError": null,
"testFilePath": "/path/to/e2e/__fixtures__/js-passing/index.test.ts",
"testResults": Array [
Object {
"ancestorTitles": Array [],
"duration": 1200,
"failureMessages": Array [],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails here on main (;

"fullName": undefined,
"numPassingAsserts": 0,
"status": "passed",
"title": "tsd typecheck",
},
],
}
`;
27 changes: 27 additions & 0 deletions src/__tests__/fail.test.ts
@@ -0,0 +1,27 @@
import { expect, test } from '@jest/globals';
import { fail } from '../fail';

const errorMessage = ` ● tsd typecheck

Argument of type 'number' is not assignable to parameter of type 'string'.

> 5 | expectType<string>(concat(1, 2));
| ^

at e2e/__fixtures__/js-failing/index.test.ts:5:1`;

test('fails', () => {
const testResult = fail({
start: 0,
end: 1200,
test: {
path: '/path/to/e2e/__fixtures__/js-failing/index.test.ts',
title: 'tsd typecheck',
},
errorMessage,
numFailed: 1,
numPassed: 3,
});

expect(testResult).toMatchSnapshot();
});
16 changes: 16 additions & 0 deletions src/__tests__/pass.test.ts
@@ -0,0 +1,16 @@
import { expect, test } from '@jest/globals';
import { pass } from '../pass';

test('pass', () => {
const testResult = pass({
start: 0,
end: 1200,
test: {
path: '/path/to/e2e/__fixtures__/js-passing/index.test.ts',
title: 'tsd typecheck',
},
numPassed: 5,
});

expect(testResult).toMatchSnapshot();
});
2 changes: 1 addition & 1 deletion src/toTestResult.js
Expand Up @@ -32,7 +32,7 @@ module.exports.toTestResult = ({
return {
ancestorTitles: [],
duration: test.duration,
failureMessages: [test.errorMessage],
failureMessages: test.errorMessage ? [test.errorMessage] : [],
fullName: test.testPath,
numPassingAsserts: test.errorMessage ? 1 : 0,
status: test.errorMessage ? 'failed' : 'passed',
Expand Down