/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v26.2.0
test/module-hooks/test-module-hooks-load-chained.js
34 строки
866 B
Antoine du Hamel
tools: add lint rule to ensure assertions are reached
07 окт 2025, 15:40
Не верифицирован
07 окт 2025, 15:40
ec26b1c
Код
Авторство
О чём код?
'use strict'; const common = require('../common'); const assert = require('assert'); const { registerHooks } = require('module'); // Test that multiple loaders works together. const hook1 = registerHooks({ load: common.mustCall((url, context, nextLoad) => { const result = nextLoad(url, context); assert.strictEqual(result.source, ''); return { source: 'exports.hello = "world"', format: 'commonjs', }; }), }); const hook2 = registerHooks({ load: common.mustCall((url, context, nextLoad) => { const result = nextLoad(url, context); assert.strictEqual(result.source, 'exports.hello = "world"'); return { source: 'export const hello = "world"', format: 'module', }; }), }); const mod = require('../fixtures/empty.js'); assert.strictEqual(mod.hello, 'world'); hook1.deregister(); hook2.deregister();