Skip to content
Open
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
14 changes: 7 additions & 7 deletions test/assertion-error/sync-basic-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
[
assertions.emptyArrayAssertion,
() => {
expect([1, 2, 3], 'to be an empty array');
expect([1, 2, 3], 'to be empty');
},
],
[
assertions.emptyObjectAssertion,
() => {
expect({ foo: 'bar' }, 'to be an empty object');
expect({ foo: 'bar' }, 'to be empty');
},
],
[
assertions.emptyStringAssertion,
() => {
expect('hello', 'to be an empty string');
expect('hello', 'to be empty');
},
],
[
assertions.errorAssertion,
() => {
expect('hello', 'to be an error');
expect('hello', 'to be an Error');
},
],
[
Expand Down Expand Up @@ -125,7 +125,7 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
[
assertions.negativeInfinityAssertion,
() => {
expect(Infinity, 'to be negative infinity');
expect(Infinity, 'to be -Infinity');
},
],
[
Expand All @@ -137,7 +137,7 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
[
assertions.nonEmptyStringAssertion,
() => {
expect('', 'to be a non empty string');
expect('', 'to be non-empty');
},
],
[
Expand Down Expand Up @@ -167,7 +167,7 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
[
assertions.positiveInfinityAssertion,
() => {
expect(-Infinity, 'to be positive infinity');
expect(-Infinity, 'to be Infinity');
},
],
[
Expand Down
114 changes: 59 additions & 55 deletions test/assertion-error/sync-basic-error.test.ts.snapshot
Original file line number Diff line number Diff line change
@@ -1,78 +1,82 @@
exports[`Sync Basic Assertion Error Snapshots > \"{arraylike} 'to be empty'\" [arraylike-to-be-empty-2s2p] > should throw a consistent AssertionError [arraylike-to-be-empty-2s2p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ [ 1, 2, 3 ], 'to be an empty array' ]",
"name": "UnknownAssertionError",
"args": [
[
1,
2,
3
],
"to be an empty array"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Expected array-like to have length 0, but had length 3",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": 3,
"expected": 0,
"diff": "simple",
"assertionId": "arraylike-to-be-empty-2s2p"
}
`;

exports[`Sync Basic Assertion Error Snapshots > \"{record} 'to be empty'\" [record-to-be-empty-2s2p] > should throw a consistent AssertionError [record-to-be-empty-2s2p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ { foo: 'bar' }, 'to be an empty object' ]",
"name": "UnknownAssertionError",
"args": [
{
"foo": "bar"
},
"to be an empty object"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{record} 'to be empty'\\" failed:\\n\\u001b[2mCompared values have no visual difference.\\u001b[22m",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": {
"foo": "bar"
},
"expected": {
"foo": "bar"
},
"diff": "simple",
"assertionId": "record-to-be-empty-2s2p"
}
`;

exports[`Sync Basic Assertion Error Snapshots > \"{string} 'to be empty'\" [string-to-be-empty-2s2p] > should throw a consistent AssertionError [string-to-be-empty-2s2p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ 'hello', 'to be an empty string' ]",
"name": "UnknownAssertionError",
"args": [
"hello",
"to be an empty string"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{string} 'to be empty'\\" failed:\\n\\u001b[32m- expected - 0\\u001b[39m\\n\\u001b[31m+ actual + 1\\u001b[39m\\n\\n\\u001b[31m+ hello\\u001b[39m",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": "hello",
"expected": "",
"diff": "simple",
"assertionId": "string-to-be-empty-2s2p"
}
`;

exports[`Sync Basic Assertion Error Snapshots > \"{string} 'to be non-empty'\" [string-to-be-non_empty-2s2p] > should throw a consistent AssertionError [string-to-be-non_empty-2s2p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ '', 'to be a non empty string' ]",
"name": "UnknownAssertionError",
"args": [
"",
"to be a non empty string"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{string} 'to be non-empty'\\" failed:\\n\\u001b[32m- expected - 1\\u001b[39m\\n\\u001b[31m+ actual + 0\\u001b[39m\\n\\n\\u001b[32m- x\\u001b[39m",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": "",
"expected": "x",
"diff": "simple",
"assertionId": "string-to-be-non_empty-2s2p"
}
`;

exports[`Sync Basic Assertion Error Snapshots > \"{unknown} 'to be -Infinity'\" [unknown-to-be-_infinity-2s1p] > should throw a consistent AssertionError [unknown-to-be-_infinity-2s1p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ Infinity, 'to be negative infinity' ]",
"name": "UnknownAssertionError",
"args": [
null,
"to be negative infinity"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{unknown} 'to be -Infinity'\\" failed:\\n\\u001b[32m- expected - 1\\u001b[39m\\n\\u001b[31m+ actual + 1\\u001b[39m\\n\\n\\u001b[32m- -Infinity\\u001b[39m\\n\\u001b[31m+ Infinity\\u001b[39m",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": null,
"expected": null,
"diff": "simple",
"assertionId": "unknown-to-be-_infinity-2s1p"
}
`;

exports[`Sync Basic Assertion Error Snapshots > \"{unknown} 'to be Infinity'\" [unknown-to-be-infinity-2s1p] > should throw a consistent AssertionError [unknown-to-be-infinity-2s1p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ -Infinity, 'to be positive infinity' ]",
"name": "UnknownAssertionError",
"args": [
null,
"to be positive infinity"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{unknown} 'to be Infinity'\\" failed:\\n\\u001b[32m- expected - 1\\u001b[39m\\n\\u001b[31m+ actual + 1\\u001b[39m\\n\\n\\u001b[32m- Infinity\\u001b[39m\\n\\u001b[31m+ -Infinity\\u001b[39m",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": null,
"expected": null,
"diff": "simple",
"assertionId": "unknown-to-be-infinity-2s1p"
}
`;

Expand Down Expand Up @@ -293,13 +297,13 @@ exports[`Sync Basic Assertion Error Snapshots > \"{unknown} 'to be a symbol' / '

exports[`Sync Basic Assertion Error Snapshots > \"{unknown} 'to be an Error' / 'to be a Error'\" [unknown-to-be-an-error-to-be-a-error-2s1p] > should throw a consistent AssertionError [unknown-to-be-an-error-to-be-a-error-2s1p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ 'hello', 'to be an error' ]",
"name": "UnknownAssertionError",
"args": [
"hello",
"to be an error"
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{unknown} 'to be an Error' / 'to be a Error'\\" failed:\\nInput not instance of Error",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": "hello",
"diff": "simple",
"assertionId": "unknown-to-be-an-error-to-be-a-error-2s1p"
}
`;

Expand Down
4 changes: 2 additions & 2 deletions test/assertion-error/sync-parametric-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
const fn = () => {
throw new Error('wrong message');
};
expect(fn, 'to throw matching', /expected/);
expect(fn, 'to throw error satisfying', /expected/);
},
],
[
Expand Down Expand Up @@ -137,7 +137,7 @@ const failingAssertions = new Map<AnyAssertion, () => void>([
[
assertions.numberWithinRangeAssertion,
() => {
expect(15, 'to be within range', [1, 10]);
expect(15, 'to be within', 1, 10);
},
],
[
Expand Down
35 changes: 16 additions & 19 deletions test/assertion-error/sync-parametric-error.test.ts.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ exports[`Sync Parametric Assertion Error Snapshots > \"{function} 'to throw a' /

exports[`Sync Parametric Assertion Error Snapshots > \"{function} 'to throw' / 'to throw error satisfying' {unknown}\" [function-to-throw-to-throw-error-satisfying-unknown-3s3p] > should throw a consistent AssertionError [function-to-throw-to-throw-error-satisfying-unknown-3s3p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ [Function: fn], 'to throw matching', /expected/ ]",
"name": "UnknownAssertionError",
"args": [
null,
"to throw matching",
{}
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Assertion \\"{function} 'to throw' / 'to throw error satisfying' {unknown}\\" failed:\\n Comparing two different types of values. Expected \\u001b[32mstring\\u001b[39m but received \\u001b[31mobject\\u001b[39m.",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"actual": {
"message": "wrong message"
},
"expected": "<string matching pattern>",
"diff": "simple",
"assertionId": "function-to-throw-to-throw-error-satisfying-unknown-3s3p"
}
`;

Expand Down Expand Up @@ -198,17 +200,12 @@ exports[`Sync Parametric Assertion Error Snapshots > \"{number} 'to be less than

exports[`Sync Parametric Assertion Error Snapshots > \"{number} 'to be within' / 'to be between' {number} {number}\" [number-to-be-within-to-be-between-number-number-4s4p] > should throw a consistent AssertionError [number-to-be-within-to-be-between-number-number-4s4p] <snapshot> 1`] = `
{
"message": "Invalid arguments. No assertion matched: [ 15, 'to be within range', [ 1, 10 ] ]",
"name": "UnknownAssertionError",
"args": [
15,
"to be within range",
[
1,
10
]
],
"code": "ERR_BUPKIS_UNKNOWN_ASSERTION"
"message": "Expected 15 to be within range [1, 10]",
"generatedMessage": false,
"name": "AssertionError",
"code": "ERR_ASSERTION",
"diff": "simple",
"assertionId": "number-to-be-within-to-be-between-number-number-4s4p"
}
`;

Expand Down