/
githubmirror
/
jest
Обзор
Документация
Войти
/
githubmirror
/
jest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/jest-runtime/src/__tests__/runtime_require_cache.test.js
46 строк
1 KB
Paul O’Shannessy
Update copyrights with Meta Platforms, restore original license in Jasmine fork (#13879)
09 фев 2023, 10:13
Не верифицирован
09 фев 2023, 10:13
6d2632a
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ 'use strict'; let createRuntime; describe('Runtime require.cache', () => { beforeEach(() => { createRuntime = require('createRuntime'); }); it('require.cache returns loaded module list as native Nodejs require does', async () => { const runtime = await createRuntime(__filename); const regularModule = runtime.requireModule( runtime.__mockRootPath, 'RegularModule', ).module; const id = regularModule.id; const cache = regularModule.require.cache; expect(cache[id]).toBe(regularModule); expect(id in cache).toBeTruthy(); expect(Object.keys(cache).includes(id)).toBeTruthy(); expect(Object.getOwnPropertyNames(cache).includes(id)).toBeTruthy(); }); it('require.cache is tolerant readonly', async () => { const runtime = await createRuntime(__filename); const regularModule = runtime.requireModule( runtime.__mockRootPath, 'RegularModule', ).module; delete regularModule.require.cache[regularModule.id]; expect(regularModule.require.cache[regularModule.id]).toBe(regularModule); regularModule.require.cache[regularModule.id] = 'something'; expect(regularModule.require.cache[regularModule.id]).toBe(regularModule); }); });