Skip to content

Commit

Permalink
Suggestion of test to automate bug detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Feb 20, 2019
1 parent 04ebef5 commit 114022f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-relay": "~0.0.19",
"execa": "^1.0.0",
"fast-check": "^1.10.1",
"flow-bin": "^0.93.0",
"glob": "^7.1.1",
"graceful-fs": "^4.1.15",
Expand Down
12 changes: 12 additions & 0 deletions packages/expect/src/__tests__/matchers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const jestExpect = require('../');
const Immutable = require('immutable');
const chalk = require('chalk');
const chalkEnabled = chalk.enabled;
const fc = require('fast-check');

beforeAll(() => {
chalk.enabled = true;
Expand Down Expand Up @@ -289,6 +290,17 @@ describe('.toStrictEqual()', () => {
expect([{a: [{a: undefined}]}]).not.toStrictEqual([{a: [{}]}]);
});

fit('distinguishes distinct values', () => {
// Given a and b values such as a different from b
// We expect `expect(a).not.toStrictEqual(b)`
fc.assert(
fc.property(fc.anything(), fc.anything(), (a, b) => {
fc.pre(JSON.stringify(a) !== JSON.stringify(b));
expect(a).not.toStrictEqual(b);
}),
);
});

it('passes when comparing same type', () => {
expect({
test: new TestClassA(1, 2),
Expand Down
22 changes: 21 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5544,6 +5544,14 @@ fancy-log@^1.3.2:
parse-node-version "^1.0.0"
time-stamp "^1.0.0"

fast-check@^1.10.1:
version "1.10.1"
resolved "https://registry.yarnpkg.com/fast-check/-/fast-check-1.10.1.tgz#a2f8f45269c85c44c700fad20cc6cfa804795c36"
integrity sha512-7TTA4QMpoSUX5nbwsOfSQAOllKFUA3FWzlTIT7V57ZN/Ju6q/wCeRXDkygNI0nVAEfPeva+fPlPlbAqizCXIUw==
dependencies:
lorem-ipsum "~1.0.6"
pure-rand "^1.6.2"

fast-deep-equal@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
Expand Down Expand Up @@ -8347,6 +8355,13 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

lorem-ipsum@~1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/lorem-ipsum/-/lorem-ipsum-1.0.6.tgz#69e9ab02bbb0991915d71b5559fe016d526f013f"
integrity sha512-Rx4XH8X4KSDCKAVvWGYlhAfNqdUP5ZdT4rRyf0jjrvWgtViZimDIlopWNfn/y3lGM5K4uuiAoY28TaD+7YKFrQ==
dependencies:
minimist "~1.2.0"

loud-rejection@^1.0.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f"
Expand Down Expand Up @@ -8901,7 +8916,7 @@ minimist@0.0.8:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=

minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0:
minimist@1.2.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
Expand Down Expand Up @@ -10637,6 +10652,11 @@ punycode@^2.1.0:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

pure-rand@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-1.6.2.tgz#90b3ae78efe36f7e6e27bfffedf934f77382e6e6"
integrity sha512-HNwHOH63m7kCxe0kWEe5jSLwJiL2N83RUUN8POniFuZS+OsbFcMWlvXgxIU2nwKy2zYG2bQan40WBNK4biYPRg==

q@0.9.7:
version "0.9.7"
resolved "https://registry.yarnpkg.com/q/-/q-0.9.7.tgz#4de2e6cb3b29088c9e4cbc03bf9d42fb96ce2f75"
Expand Down

0 comments on commit 114022f

Please sign in to comment.