Skip to content

Commit

Permalink
node assert snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Mar 29, 2017
1 parent 5109514 commit 059bbff
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
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');
});

0 comments on commit 059bbff

Please sign in to comment.