Skip to content

Object attributes are being copied instead of referenced #981

Open
@Philipp3211

Description

@Philipp3211

When object attributes are given as parameter to the createMock function, they are copied instead of referenced. This is unexpected and has the disadvantage, that changes on the original object are not reflected in the mock:

interface TestInterface {
    testAttribute: {
        id: number
    };
}

const test = {
    id: 0
};

const testMock = createMock<TestInterface>({testAttribute: test});

test.id = 1;

const finalTest = testMock.testAttribute.id === test.id; // expected true, but is actually false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions