Skip to content

Commit

Permalink
Use strict equality check by default (#68)
Browse files Browse the repository at this point in the history
* test: Add failing test case.

*  fix: Use strict equality comparison by default.
  • Loading branch information
karol-majewski committed Feb 11, 2020
1 parent 75b646c commit c12ce82
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions fixtures/jest/failing-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ if (process.env.FAILING !== "0") {
m.expect(source).toHaveSubscriptions(subs);
})
);

test(
"it should fail the strict comparison check when excess properties are present",
marbles(m => {
interface Person {
name: string;
age?: number;
}

const source = m.cold<Person>("a-", {
a: { name: "Bob", age: undefined }
});
const expected = m.cold<Person>("a-", { a: { name: "Bob" } });

m.expect(source).toBeObservable(expected);
})
);
});

describe("observe", () => {
Expand Down
7 changes: 5 additions & 2 deletions source/jest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function configure(
} {
const { marbles } = _configure({
...configuration,
assertDeepEqual: (a, e) => expect(a).toEqual(e),
assertDeepEqual: (a, e) => expect(a).toStrictEqual(e),
frameworkMatcher: true
});

Expand All @@ -66,7 +66,10 @@ export function configure(
)
);
} else {
t(c.name, marbles((m, ...rest: any[]) => func(m, c, ...rest)));
t(
c.name,
marbles((m, ...rest: any[]) => func(m, c, ...rest))
);
}
}, cases);
});
Expand Down

3 comments on commit c12ce82

@iamchangming
Copy link

Choose a reason for hiding this comment

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

How could this "default" config be overwritten? It is after "...configuration,".

@cartant
Copy link
Owner

Choose a reason for hiding this comment

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

@iamchangming There is no anticipation that you would you ever need to override it. This is a framework-specific configuration and the whole point of it is to automatically configure this assertion for the framework - Jest, in this case. If you need to override it, you should not be using this import location. Use the base, framework-agnostic import location.

@iamchangming
Copy link

Choose a reason for hiding this comment

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

From Readme, configure should be able to overwrite config.

import { configure } from "rxjs-marbles/mocha";
const { cases, marbles } = configure({ run: false });

Tests are failing because of this commit. And there is no way to overwrite this back!

Please sign in to comment.