Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-next-dynamic

Package Overview
Dependencies
Maintainers
30
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-next-dynamic - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

37

index.js

@@ -5,8 +5,10 @@ const mockInitializers = [];

if (mockInitializers.length) {
const promises = mockInitializers.map(preload => preload());
// Copy and empty out `mockInitializers` right away so that any newly
// enqueued components are found in the next pass.
const initializers = mockInitializers.slice();
mockInitializers.length = 0;
// While loading the components in this round of initializers, more
// components may have been dynamically loaded, adding more promises we
// should wait for.
return Promise.all(promises).then(preloadAll);
// components may have been dynamically imported, adding more initializers
// we should run and await.
return Promise.all(initializers.map(preload => preload())).then(preloadAll);
} else {

@@ -17,12 +19,21 @@ return Promise.resolve();

jest.doMock("next/dynamic", () => {
const { default: dynamic } = jest.requireActual("next/dynamic");
jest.doMock(
"next/dynamic",
() => {
const { default: dynamic } = jest.requireActual("next/dynamic");
const mockDynamic = (...args) => {
const LoadableComponent = dynamic(...args);
mockInitializers.push(() => LoadableComponent.preload());
return LoadableComponent;
};
const mockDynamic = (...args) => {
const LoadableComponent = dynamic(...args);
mockInitializers.push(() => LoadableComponent.preload());
return LoadableComponent;
};
return mockDynamic;
});
return mockDynamic;
},
// In order to more easily include this feature in shared Jest setups (like
// presets), use `virtual: true` to avoid throwing an error when `next` isn't
// actually installed.
{
virtual: true
}
);
{
"name": "jest-next-dynamic",
"version": "0.2.0",
"version": "0.3.0",
"main": "index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc