diff options
-rw-r--r-- | test/js/bun/test/__snapshots__/test-test.test.ts.snap | 3 | ||||
-rw-r--r-- | test/js/bun/test/test-fixture-diff-indexed-properties.js | 12 | ||||
-rw-r--r-- | test/js/bun/test/test-test.test.ts | 18 |
3 files changed, 33 insertions, 0 deletions
diff --git a/test/js/bun/test/__snapshots__/test-test.test.ts.snap b/test/js/bun/test/__snapshots__/test-test.test.ts.snap new file mode 100644 index 000000000..31c5d310b --- /dev/null +++ b/test/js/bun/test/__snapshots__/test-test.test.ts.snap @@ -0,0 +1,3 @@ +// Bun Snapshot v1, https://goo.gl/fbAQLP + +exports[`expect().toEqual() on objects with property indices doesn't print undefined 1`] = `"expect(received).toEqual(expected)\n\n {\n+ \"0\": 0,\n+ \"1\": 1,\n+ \"10\": 10,\n+ \"11\": 11,\n+ \"12\": 12,\n+ \"13\": 13,\n+ \"14\": 14,\n+ \"15\": 15,\n+ \"2\": 2,\n+ \"3\": 3,\n+ \"4\": 4,\n+ \"5\": 5,\n+ \"6\": 6,\n+ \"7\": 7,\n+ \"8\": 8,\n+ \"9\": 9\n- \"0\": 123,\n- \"1\": 123,\n- \"10\": 123,\n- \"11\": 123,\n- \"12\": 123,\n- \"13\": 123,\n- \"14\": 123,\n- \"15\": 123,\n- \"2\": 123,\n- \"3\": 123,\n- \"4\": 123,\n- \"5\": 123,\n- \"6\": 123,\n- \"7\": 123,\n- \"8\": 123,\n- \"9\": 123\n }\n\n- Expected - 16\n+ Received + 16\n\n "`; diff --git a/test/js/bun/test/test-fixture-diff-indexed-properties.js b/test/js/bun/test/test-fixture-diff-indexed-properties.js new file mode 100644 index 000000000..b7a1acb23 --- /dev/null +++ b/test/js/bun/test/test-fixture-diff-indexed-properties.js @@ -0,0 +1,12 @@ +import { test, expect } from "bun:test"; + +test("indexed property diff", () => { + var obj = {}; + var objB = {}; + for (let i = 0; i < 16; i++) { + obj[i] = i; + objB[i] = 123; + } + + expect(obj).toEqual(objB); +}); diff --git a/test/js/bun/test/test-test.test.ts b/test/js/bun/test/test-test.test.ts index fc3e3c89e..f2c22fbcf 100644 --- a/test/js/bun/test/test-test.test.ts +++ b/test/js/bun/test/test-test.test.ts @@ -2775,3 +2775,21 @@ it("test timeouts when expected", () => { expect(err).toContain("timed out after 10ms"); expect(err).not.toContain("unreachable code"); }); + +it("expect().toEqual() on objects with property indices doesn't print undefined", () => { + const path = join(realpathSync(tmpdir()), "test-fixture-diff-indexed-properties.test.js"); + copyFileSync(join(import.meta.dir, "test-fixture-diff-indexed-properties.js"), path); + const { stdout, stderr, exited } = spawnSync({ + cmd: [bunExe(), "test", path], + stdout: "pipe", + stderr: "pipe", + env: bunEnv, + cwd: realpathSync(dirname(path)), + }); + + let err = stderr!.toString(); + err = err.substring(err.indexOf("expect(received).toEqual(expected)"), err.indexOf("at ")); + + expect(err).toMatchSnapshot(); + expect(err).not.toContain("undefined"); +}); |