Skip to content

Commit

Permalink
fix error message display (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgruber authored Jun 27, 2017
1 parent d01cc79 commit 24efce0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/test/test.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

.error-message {
font-size: 12px;
margin: 10px 0 0 0;
margin: 0 0 10px 13px;
color: var(--red500);
}

Expand Down
4 changes: 1 addition & 3 deletions src/components/test/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ class Test extends React.Component {
{ !isHook && <Icon name='timer' className={ cx('duration-icon', speed) } size={ 18 } /> }
</div>
</header>
{ !!err.name && !!err.message && (
<p className={ cx('error-message') }>{ `${err.name}: ${err.message}` }</p>
) }
{ !!err.message && <p className={ cx('error-message') }>{ err.message }</p> }
<div className={ cx('body') }>
{ <CodeSnippet className={ cx('code-snippet') } code={ err.estack } highlight={ false } label='Stack Trace' /> }
{ <CodeSnippet className={ cx('code-snippet') } code={ err.diff } lang='diff' label='Diff' /> }
Expand Down
20 changes: 9 additions & 11 deletions test/spec/components/test/test.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ const failingTest = {
pending: false,
code: 'var o = retObj();\no.should.eql({});\ndone();',
err: {
name: 'AssertionError',
actual: '{\n \"employees\": {\n \"employee\": [\n {\n \"firstName\": \"Tom\"\n \"id\": \"1\"\n \"lastName\": \"Cruise\"\n }\n {\n \"firstName\": \"Maria\"\n \"id\": \"2\"\n \"lastName\": \"Sharapova\"\n }\n {\n \"firstName\": \"James\"\n \"id\": \"3\"\n \"lastName\": \"Bond\"\n }\n ]\n }\n}',
expected: '{}',
operator: 'to equal',
message: 'expected { employees: \n { employee: \n [ { id: \'1\', firstName: \'Tom\', lastName: \'Cruise\' },\n { id: \'2\', firstName: \'Maria\', lastName: \'Sharapova\' },\n { id: \'3\', firstName: \'James\', lastName: \'Bond\' } ] } } to equal {}',
generatedMessage: true,
showDiff: true,
message: 'AssertionError: expected { employees: \n { employee: \n [ { id: \'1\', firstName: \'Tom\', lastName: \'Cruise\' },\n { id: \'2\', firstName: \'Maria\', lastName: \'Sharapova\' },\n { id: \'3\', firstName: \'James\', lastName: \'Bond\' } ] } } to equal {}',
estack: 'AssertionError: expected { employees: \n { employee: \n [ { id: \'1\', firstName: \'Tom\', lastName: \'Cruise\' },\n { id: \'2\', firstName: \'Maria\', lastName: \'Sharapova\' },\n { id: \'3\', firstName: \'James\', lastName: \'Bond\' } ] } } to equal {}\n at Assertion.prop.(anonymous function) (node_modules/should/lib/should.js:61:14)\n at Context.<anonymous> (test-functional/test.js:38:16)',
diff: '- {\n- \"employees\": {\n- \"employee\": [\n- {\n- \"firstName\": \"Tom\"\n- \"id\": \"1\"\n- \"lastName\": \"Cruise\"\n- }\n- {\n- \"firstName\": \"Maria\"\n- \"id\": \"2\"\n- \"lastName\": \"Sharapova\"\n- }\n- {\n- \"firstName\": \"James\"\n- \"id\": \"3\"\n- \"lastName\": \"Bond\"\n- }\n- ]\n- }\n- }\n+ {}\n'
},
Expand Down Expand Up @@ -132,7 +126,9 @@ const beforeHookFailed = {
pending: false,
code: 'shouldFail\n ? console.log(a)\n : console.log(\'This is the before hook.\');',
err: {
estack: 'ReferenceError: a is not defined\n at Context.before (helpers.js:42:21)'
message: 'ReferenceError: a is not defined',
estack: 'ReferenceError: a is not defined\n at Context.before (helpers.js:42:21)',
diff: undefined
},
isRoot: false,
uuid: '1e445313-1f42-413a-9518-0d970b8179f0',
Expand Down Expand Up @@ -169,7 +165,9 @@ const afterHookFailed = {
pending: false,
code: 'shouldFail\n ? console.log(a)\n : console.log(\'This is the after hook.\');',
err: {
estack: 'ReferenceError: a is not defined\n at Context.before (helpers.js:42:21)'
message: 'ReferenceError: a is not defined',
estack: 'ReferenceError: a is not defined\n at Context.before (helpers.js:42:21)',
diff: undefined
},
isRoot: false,
uuid: '1e445313-1f42-413a-9518-0d970b8179f0',
Expand Down Expand Up @@ -278,7 +276,7 @@ describe('<Test />', () => {
it('renders a failed before hook', () => {
const { header, snippets, errorMsg } = getInstance({ test: beforeHookFailed });
expect(snippets).to.have.lengthOf(3);
expect(errorMsg).to.have.lengthOf(0);
expect(errorMsg).to.have.lengthOf(1);
header.simulate('click');
expect(toggleSpy.calledOnce).to.equal(true);
expect(setStateSpy.calledOnce).to.equal(true);
Expand All @@ -296,7 +294,7 @@ describe('<Test />', () => {
it('renders a failed after hook', () => {
const { header, snippets, errorMsg } = getInstance({ test: afterHookFailed });
expect(snippets).to.have.lengthOf(3);
expect(errorMsg).to.have.lengthOf(0);
expect(errorMsg).to.have.lengthOf(1);
header.simulate('click');
expect(toggleSpy.calledOnce).to.equal(true);
expect(setStateSpy.calledOnce).to.equal(true);
Expand Down

0 comments on commit 24efce0

Please sign in to comment.