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 模块中导入的。

import { describe, it } from 'node:test';const { describe, it } = require('node:test');