Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extreme slow processing of mocks that are created via the mock() function #128

Open
MarcoLeko opened this issue Oct 19, 2023 · 0 comments
Open

Comments

@MarcoLeko
Copy link

MarcoLeko commented Oct 19, 2023

When creating mock objects with the mock() function and the mock object is of a somewhat reasonable size like here:

const mockContent = {
 id: 'foo',
 routes: [],
 externalIds: [],
 visibilities: [],
 ageRatings: [],
 productionYear: undefined,
 productionCountries: [],
 media: {
   ageRatings: [],
   formats: [],
 },
 titles: [
   {
     text: 'This is some text',
     language: {
       code: 'de',
       standard: null,
       name: 'German',
     },
     type: 'foo',
     source: 'some source',
   },
 ],
 descriptions: [
   {
     text: 'This is some text',
     language: {
       code: 'de',
       standard: null,
       name: 'German',
     },
     type: 'foo',
     source: 'some source',
   },
 ],
};

it seems that the test executions are getting exponentially slower when creating the mock-object after each test-case. I've provided a super simple reproducible environment, but I fear unfurtunately the results are really bad - last test takes over 30 secs(!):

Screenshot 2023-10-19 at 15 32 39

The environment which can be used to test this is: https://stackblitz.com/edit/node-lqkljc?file=index.test.ts

After doing some profiling (this profiling snapshot is not from the stackblitz reproducible environment) it is clear that calling mock may take up, up 15sec just because of a function that is called ownKeys and not sure if this is a recursive call, but it is called uncountable times.

Screenshot 2023-10-19 at 15 41 18

This is a severe issue that prevents me from using this library. In general I do really like this lib as enables to create partial mock object and still have type safety without ugly castings. So getting this fixed is really appreciated. Hope you can work with this initial data.

@MarcoLeko MarcoLeko changed the title Extreme slow processing of mocks that are creating via mock() function Extreme slow processing of mocks that are created via the mock() function Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant