Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

View File

@@ -0,0 +1,34 @@
import { strictEqual } from 'assert'
import Hook from '../../index.js'
/* eslint-disable import/first */
import {
/* eslint-disable import/no-named-default */
default as bar,
foo,
aFunc,
baz
} from '../fixtures/bundle.mjs'
Hook((exports, name) => {
if (/bundle\.mjs/.test(name) === false) return
const bar = exports.default
exports.default = function wrappedBar () {
return bar() + '-wrapped'
}
const foo = exports.foo
exports.foo = function wrappedFoo () {
return foo() + '-wrapped'
}
const aFunc = exports.aFunc
exports.aFunc = function wrappedAFunc () {
return aFunc() + '-wrapped'
}
})
strictEqual(bar(), '42-wrapped')
strictEqual(foo(), 'foo-wrapped')
strictEqual(aFunc(), 'a-wrapped')
strictEqual(baz(), 'baz')