为什么我的测试被跳过了

问题描述 投票:0回答:3

我使用 jest 进行了此测试,但第二种方法被跳过,为什么?

const stringToTest = JSON.stringify({"filename":"9F6148567F8.jpg","id":"ss9:blob-ref:29e4b813a","diskp":"gotchi","mikoId":"e3f813a","content":"gotchi, 18/08/13 at 11:57 AM"});

describe('uri 的正则表达式', () => {

it('should match expected URI', () => {
    expect(matchUriRE.test(stringToTest)).toBe(true);
});

//below method skipped why?
it('should not be bull or undefined'), () => {
    expect(matchUriRE.test(stringToTest)).not.toBeNull;
    expect(matchUriRE.test(stringToTest)).not.toBe(null);
    expect(matchUriRE.test(stringToTest)).not.toBeUndefined();
};
}) 

结果:

Test Suites: 1 passed, 1 total
Tests:       1 skipped, 1 passed, 2 total
javascript jestjs
3个回答
12
投票

简单的错字。删除测试描述后的括号并将其放在测试上的

}
后面。

it('should not be bull or undefined'), () => {

应该是

it('should not be bull or undefined', () => {

4
投票

这里不是这种情况,但仅供将来参考,因为我错误地只添加了标签

经验:

it.only("test name", () => {})

这只会运行此测试并忽略同一文件中的其他测试


0
投票

我猜如果您使用的正则表达式模式有问题,您的测试可能会被跳过。尝试停止测试并再次运行。

© www.soinside.com 2019 - 2024. All rights reserved.