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');