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

node 'assert' errors snapshot tests #3225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions integration_tests/__tests__/__snapshots__/failures-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,73 @@ Ran all test suites matching \\"assertion-count-test.js\\".
",
}
`;

exports[`works with node assert 1`] = `
Object {
"rest": " FAIL __tests__/node-assertion-error-test.js
● assert

AssertionError: false == true

at Object.test (__tests__/node-assertion-error-test.js:16:3)

● assert with a message

AssertionError: this is a message

at Object.test (__tests__/node-assertion-error-test.js:20:3)

● assert.ok

AssertionError: false == true

at Object.test (__tests__/node-assertion-error-test.js:24:10)

● assert.ok with a message

AssertionError: this is a message

at Object.test (__tests__/node-assertion-error-test.js:28:10)

● assert.equal

AssertionError: 1 == 2

at Object.test (__tests__/node-assertion-error-test.js:32:10)

● assert.equal with a message

AssertionError: this is a message

at Object.test (__tests__/node-assertion-error-test.js:36:10)

● assert.deepEqual

AssertionError: { a: { b: { c: 5 } } } deepEqual { a: { b: { c: 6 } } }

at Object.test (__tests__/node-assertion-error-test.js:40:10)

● assert.deepEqual with a message

AssertionError: this is a message

at Object.test (__tests__/node-assertion-error-test.js:44:10)

✕ assert
✕ assert with a message
✕ assert.ok
✕ assert.ok with a message
✕ assert.equal
✕ assert.equal with a message
✕ assert.deepEqual
✕ assert.deepEqual with a message

",
"summary": "Test Suites: 1 failed, 1 total
Tests: 8 failed, 8 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites matching \\"node-assertion-error-test.js\\".
",
}
`;
7 changes: 7 additions & 0 deletions integration_tests/__tests__/failures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ test('throwing not Error objects', () => {
extractSummary(stderr),
)).toMatchSnapshot();
});

test('works with node assert', () => {
const {stderr} = runJest(dir, ['node-assertion-error-test.js']);
expect(stripInconsistentStackLines(
extractSummary(stderr),
)).toMatchSnapshot();
});
45 changes: 45 additions & 0 deletions integration_tests/failures/__tests__/node-assertion-error-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+jsinfra
*/

'use strict';

const assert = require('assert');

test('assert', () => {
assert(false);
});

test('assert with a message', () => {
assert(false, 'this is a message');
});

test('assert.ok', () => {
assert.ok(false);
});

test('assert.ok with a message', () => {
assert.ok(false, 'this is a message');
});

test('assert.equal', () => {
assert.equal(1, 2);
});

test('assert.equal with a message', () => {
assert.equal(1, 2, 'this is a message');
});

test('assert.deepEqual', () => {
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 6}}});
});

test('assert.deepEqual with a message', () => {
assert.deepEqual({a: {b: {c: 5}}}, {a: {b: {c: 7}}}, 'this is a message');
});