describe() 和 it() 别名
¥describe() and it() aliases
套件和测试也可以使用 describe() 和 it() 函数编写。describe() 是 suite() 的别名,it() 是 test() 的别名。
¥Suites and tests can also be written using the describe() and it()
functions. describe() is an alias for suite(), and it() is an
alias for test().
describe('A thing', () => {
it('should work', () => {
assert.strictEqual(1, 1);
});
it('should be ok', () => {
assert.strictEqual(2, 2);
});
describe('a nested thing', () => {
it('should work', () => {
assert.strictEqual(3, 3);
});
});
}); describe() 和 it() 是从 node:test 模块导入的。
¥describe() and it() are imported from the node:test module.
import { describe, it } from 'node:test';const { describe, it } = require('node:test');