In the "test1", the property value foo
of testObject
already became to bravo
. Thus, both "test1" and "test2" will fail.
import { assert as Assert } from "chai";
describe("test", (): void => {
const testObject: { foo: string; } = { foo: "alpha" };
it("test1", (): void => {
Assert.deepEqual(testObject, { foo: "alpha" });
});
testObject.foo = "bravo";
it("test2", (): void => {
Assert.deepEqual(testObject, { foo: "bravo" });
});
});
I need to solve this for testing of my function, which among it's functionality clones the array:
- Create array
- Deeply clone array
- Check has array been cloned correctly
- Mutate cloned array (will break step 3 tests)
- Make sure that initial array was not changed
Aucun commentaire:
Enregistrer un commentaire