Skip to content

Commit 2ef4a06

Browse files
test: name the deferred bundle snapshots
The two compilers run concurrently, so an unnamed snapshot keys on call order and the two bundles swapped places between runs. Key each on its bundle name instead. Refs #17121
1 parent 205d446 commit 2ef4a06

3 files changed

Lines changed: 130 additions & 128 deletions

File tree

‎test/configCases/side-effects/pure-deferred-import/__snapshots__/ConfigCacheTest.snap‎

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile 1`] = `
3+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle0.js 1`] = `
44
"/******/ (() => { // webpackBootstrap
55
/******/ var __webpack_modules__ = ({
66
@@ -169,125 +169,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
169169
;"
170170
`;
171171

172-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile 2`] = `
173-
"/******/ (() => { // webpackBootstrap
174-
/******/ var __webpack_modules__ = ({
175-
176-
/***/ 896
177-
/*!*********************!*\\\\
178-
!*** ./pure-cjs.js ***!
179-
\\\\*********************/
180-
(__unused_webpack_module, exports) {
181-
182-
exports.l = function (a, b) {
183-
return a * b;
184-
};
185-
186-
187-
/***/ }
188-
189-
/******/ });
190-
/************************************************************************/
191-
/******/ // The module cache
192-
/******/ const __webpack_module_cache__ = {};
193-
/******/
194-
/******/ // The require function
195-
/******/ function __webpack_require__(moduleId) {
196-
/******/ // Check if module is in cache
197-
/******/ const cachedModule = __webpack_module_cache__[moduleId];
198-
/******/ if (cachedModule !== undefined) {
199-
/******/ if (cachedModule.error !== undefined) throw cachedModule.error;
200-
/******/ return cachedModule.exports;
201-
/******/ }
202-
/******/ // Create a new module (and put it into the cache)
203-
/******/ const module = __webpack_module_cache__[moduleId] = {
204-
/******/ // no module.id needed
205-
/******/ // no module.loaded needed
206-
/******/ exports: {}
207-
/******/ };
208-
/******/
209-
/******/ // Execute the module function
210-
/******/ module.evaluating = true;
211-
/******/ try {
212-
/******/ if (!(moduleId in __webpack_modules__)) {
213-
/******/ delete __webpack_module_cache__[moduleId];
214-
/******/ const e = new Error(\\"Cannot find module '\\" + moduleId + \\"'\\");
215-
/******/ e.code = 'MODULE_NOT_FOUND';
216-
/******/ throw e;
217-
/******/ }
218-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
219-
/******/ module.evaluating = false;
220-
/******/ } catch(e) {
221-
/******/ module.evaluating = false;
222-
/******/ module.error = e;
223-
/******/ throw e;
224-
/******/ }
225-
/******/
226-
/******/ // Return the exports of the module
227-
/******/ return module.exports;
228-
/******/ }
229-
/******/
230-
/************************************************************************/
231-
/******/ /* webpack/runtime/make optimized deferred namespace object */
232-
/******/ __webpack_require__.zO = function(moduleId, mode, asyncDeps, syncDeps) {
233-
/******/ const r = this;
234-
/******/
235-
/******/ const obj = {
236-
/******/ get a() {
237-
/******/ const cachedModule = __webpack_module_cache__[moduleId];
238-
/******/ if (cachedModule !== undefined && (cachedModule.evaluating || cachedModule.evaluatingAsync)) throw new TypeError(\\"Cannot access a deferred module namespace while the module is being evaluated\\");
239-
/******/ if (syncDeps) for (var i = 0; i < syncDeps.length; i++) {
240-
/******/ const depModule = __webpack_module_cache__[syncDeps[i]];
241-
/******/ if (depModule !== undefined && (depModule.evaluating || depModule.evaluatingAsync)) throw new TypeError(\\"Cannot access a deferred module namespace while a dependency is being evaluated\\");
242-
/******/ }
243-
/******/ let exports = r(moduleId);
244-
/******/
245-
/******/ if(mode & 8 || (mode & 4 && exports.__esModule)) Object.defineProperty(this, \\"a\\", { value: exports });
246-
/******/ return exports;
247-
/******/ }
248-
/******/ };
249-
/******/
250-
/******/ return obj;
251-
/******/ };
252-
/******/
253-
/************************************************************************/
254-
let __webpack_exports__ = {};
255-
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
256-
(() => {
257-
\\"use strict\\";
258-
/*!******************************!*\\\\
259-
!*** ./index.js + 2 modules ***!
260-
\\\\******************************/
261-
262-
// DEFERRED EXTERNAL MODULE: ./pure-cjs.js
263-
var pure_cjs_deferred = /*#__PURE__*/__webpack_require__.zO(896, /* default-with-named */ 2);
264-
;// ./side.js
265-
function extra(a) {
266-
return a + 1;
267-
}
268-
269-
;// ./lib.js
270-
271-
272-
273-
function readLazy(a, b) {
274-
return pure_cjs_deferred.a/* mul */.l(a, b) + extra(0);
275-
}
276-
277-
;// ./index.js
278-
279-
280-
it(\\"should evaluate the deferred module on access\\", () => {
281-
expect(readLazy(6, 7)).toBe(43);
282-
});
283-
284-
})();
285-
286-
/******/ })()
287-
;"
288-
`;
289-
290-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile 3`] = `
172+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle0.js 2`] = `
291173
"/******/ (() => { // webpackBootstrap
292174
/******/ var __webpack_modules__ = ({
293175
@@ -456,7 +338,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
456338
;"
457339
`;
458340

459-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile 4`] = `
341+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle1.js 1`] = `
460342
"/******/ (() => { // webpackBootstrap
461343
/******/ var __webpack_modules__ = ({
462344
@@ -574,7 +456,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
574456
;"
575457
`;
576458

577-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (1st) 1`] = `
459+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle1.js 2`] = `
578460
"/******/ (() => { // webpackBootstrap
579461
/******/ var __webpack_modules__ = ({
580462
@@ -692,7 +574,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
692574
;"
693575
`;
694576

695-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (1st) 2`] = `
577+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (1st): bundle0.js 1`] = `
696578
"/******/ (() => { // webpackBootstrap
697579
/******/ var __webpack_modules__ = ({
698580
@@ -861,7 +743,125 @@ it(\\"should evaluate the deferred module on access\\", () => {
861743
;"
862744
`;
863745

864-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (2nd) 1`] = `
746+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (1st): bundle1.js 1`] = `
747+
"/******/ (() => { // webpackBootstrap
748+
/******/ var __webpack_modules__ = ({
749+
750+
/***/ 896
751+
/*!*********************!*\\\\
752+
!*** ./pure-cjs.js ***!
753+
\\\\*********************/
754+
(__unused_webpack_module, exports) {
755+
756+
exports.l = function (a, b) {
757+
return a * b;
758+
};
759+
760+
761+
/***/ }
762+
763+
/******/ });
764+
/************************************************************************/
765+
/******/ // The module cache
766+
/******/ const __webpack_module_cache__ = {};
767+
/******/
768+
/******/ // The require function
769+
/******/ function __webpack_require__(moduleId) {
770+
/******/ // Check if module is in cache
771+
/******/ const cachedModule = __webpack_module_cache__[moduleId];
772+
/******/ if (cachedModule !== undefined) {
773+
/******/ if (cachedModule.error !== undefined) throw cachedModule.error;
774+
/******/ return cachedModule.exports;
775+
/******/ }
776+
/******/ // Create a new module (and put it into the cache)
777+
/******/ const module = __webpack_module_cache__[moduleId] = {
778+
/******/ // no module.id needed
779+
/******/ // no module.loaded needed
780+
/******/ exports: {}
781+
/******/ };
782+
/******/
783+
/******/ // Execute the module function
784+
/******/ module.evaluating = true;
785+
/******/ try {
786+
/******/ if (!(moduleId in __webpack_modules__)) {
787+
/******/ delete __webpack_module_cache__[moduleId];
788+
/******/ const e = new Error(\\"Cannot find module '\\" + moduleId + \\"'\\");
789+
/******/ e.code = 'MODULE_NOT_FOUND';
790+
/******/ throw e;
791+
/******/ }
792+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
793+
/******/ module.evaluating = false;
794+
/******/ } catch(e) {
795+
/******/ module.evaluating = false;
796+
/******/ module.error = e;
797+
/******/ throw e;
798+
/******/ }
799+
/******/
800+
/******/ // Return the exports of the module
801+
/******/ return module.exports;
802+
/******/ }
803+
/******/
804+
/************************************************************************/
805+
/******/ /* webpack/runtime/make optimized deferred namespace object */
806+
/******/ __webpack_require__.zO = function(moduleId, mode, asyncDeps, syncDeps) {
807+
/******/ const r = this;
808+
/******/
809+
/******/ const obj = {
810+
/******/ get a() {
811+
/******/ const cachedModule = __webpack_module_cache__[moduleId];
812+
/******/ if (cachedModule !== undefined && (cachedModule.evaluating || cachedModule.evaluatingAsync)) throw new TypeError(\\"Cannot access a deferred module namespace while the module is being evaluated\\");
813+
/******/ if (syncDeps) for (var i = 0; i < syncDeps.length; i++) {
814+
/******/ const depModule = __webpack_module_cache__[syncDeps[i]];
815+
/******/ if (depModule !== undefined && (depModule.evaluating || depModule.evaluatingAsync)) throw new TypeError(\\"Cannot access a deferred module namespace while a dependency is being evaluated\\");
816+
/******/ }
817+
/******/ let exports = r(moduleId);
818+
/******/
819+
/******/ if(mode & 8 || (mode & 4 && exports.__esModule)) Object.defineProperty(this, \\"a\\", { value: exports });
820+
/******/ return exports;
821+
/******/ }
822+
/******/ };
823+
/******/
824+
/******/ return obj;
825+
/******/ };
826+
/******/
827+
/************************************************************************/
828+
let __webpack_exports__ = {};
829+
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
830+
(() => {
831+
\\"use strict\\";
832+
/*!******************************!*\\\\
833+
!*** ./index.js + 2 modules ***!
834+
\\\\******************************/
835+
836+
// DEFERRED EXTERNAL MODULE: ./pure-cjs.js
837+
var pure_cjs_deferred = /*#__PURE__*/__webpack_require__.zO(896, /* default-with-named */ 2);
838+
;// ./side.js
839+
function extra(a) {
840+
return a + 1;
841+
}
842+
843+
;// ./lib.js
844+
845+
846+
847+
function readLazy(a, b) {
848+
return pure_cjs_deferred.a/* mul */.l(a, b) + extra(0);
849+
}
850+
851+
;// ./index.js
852+
853+
854+
it(\\"should evaluate the deferred module on access\\", () => {
855+
expect(readLazy(6, 7)).toBe(43);
856+
});
857+
858+
})();
859+
860+
/******/ })()
861+
;"
862+
`;
863+
864+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (2nd): bundle0.js 1`] = `
865865
"/******/ (() => { // webpackBootstrap
866866
/******/ var __webpack_modules__ = ({
867867
@@ -1030,7 +1030,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
10301030
;"
10311031
`;
10321032

1033-
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (2nd) 2`] = `
1033+
exports[`ConfigCacheTestCases side-effects pure-deferred-import pure-deferred-import should pre-compile to fill disk cache (2nd): bundle1.js 1`] = `
10341034
"/******/ (() => { // webpackBootstrap
10351035
/******/ var __webpack_modules__ = ({
10361036

‎test/configCases/side-effects/pure-deferred-import/__snapshots__/ConfigTest.snap‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

3-
exports[`ConfigTestCases side-effects pure-deferred-import pure-deferred-import should compile 1`] = `
3+
exports[`ConfigTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle0.js 1`] = `
44
"/******/ (() => { // webpackBootstrap
55
/******/ var __webpack_modules__ = ({
66
@@ -169,7 +169,7 @@ it(\\"should evaluate the deferred module on access\\", () => {
169169
;"
170170
`;
171171

172-
exports[`ConfigTestCases side-effects pure-deferred-import pure-deferred-import should compile 2`] = `
172+
exports[`ConfigTestCases side-effects pure-deferred-import pure-deferred-import should compile: bundle1.js 1`] = `
173173
"/******/ (() => { // webpackBootstrap
174174
/******/ var __webpack_modules__ = ({
175175

‎test/configCases/side-effects/pure-deferred-import/webpack.config.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const snapshotBundle = (name) => (compiler) => {
1717
(
1818
/** @type {Record<string, import("webpack-sources").Source>} */ assets
1919
) => {
20-
expect(assets[name].source()).toMatchSnapshot();
20+
// Named: the two compilers run concurrently, so an unnamed snapshot
21+
// would key on call order and the two bundles could swap places.
22+
expect(assets[name].source()).toMatchSnapshot(name);
2123
}
2224
);
2325
}

0 commit comments

Comments
 (0)