node-mongoose-fixtures icon indicating copy to clipboard operation
node-mongoose-fixtures copied to clipboard

Upgrading from 0.2.4 to 0.3.0

Open richardlay opened this issue 6 years ago • 1 comments

My tests broke when I upgraded from 0.2.4 to 0.3.0.

An example scenario:

fixtures.save('mockAccount', {
    account: {
        username: 'one', password: 'pass'
    }
});

fixtures('mockAccount', function(err, data) {
    
});

In 0.2.4, data looked like

[
    {
        username: "one",
        password: "pass"
    }
]

In 0.3.0, data looks like

[
    [
        {
            username: "one",
            password: "pass"
        }
    ]
]

Looks like it is caused from a change in lib/index.js line 28: create was changed to insertMany.

Is this expected?

richardlay avatar Feb 18 '19 05:02 richardlay

Just looking into this a bit more, in lib/index.js line 29 the arguments index contains the result of the insert.

For create, a single item fixture such as the one I'm using above will return an object as the result. However with insertMany it will return an array.

Is there any chance we can keep the previous behaviour for single item fixtures?

richardlay avatar Feb 18 '19 05:02 richardlay