describe('All Test in this describe will be run', () => {
xtest('Except this test- This test will not be run', () => {
expect(true).toBe(true);
});
test('This test will be run', () => {
expect(true).toBe(true);
});
});
描述中的多个测试
xdescribe('All tests in this describe will be skipped', () => {
test('This test will be skipped', () => {
expect(true).toBe(true);
});
test('This test will be skipped', () => {
expect(true).toBe(true);
});
});
describe('some amazing test suite', () => {
test('number one', () => {
// some testing logic
}
test('number two', () => {
// some testing logic
}
...
test('number x', () => {
// some testing logic
}
test.only('new test or the one needs debugging', () => {
// Now when you run this suite only this test will run
// so now you are free to debug or work on business logic
// instead to wait for other tests to pass every time you run jest
// You can remove `.only` flag once you're done!
}
}
test('test 1', () => {})
test('test 2', () => {})
test('test 3', () => {})
test.only('test 4', () => {}) // only this would run in this file
多个问题:
test('test 1', () => {})
test.only('test 2', () => {}) // only this
test('test 3', () => {})
test.only('test 4', () => {}) // and this would run in this file
描述:
desribe(() => {
test('test 1', () => {}) // nothing will run here
test.only('test 2', () => {}) //
})
desribe.only(() => {
test('test 1', () => {})
test.only('test 2', () => {}) // only this test
test('test 3', () => {})
test.only('test 4', () => {}) // and this one would be run (because this is the only active describe block)
})
desribe(() => {
test('test 1', () => {}). // No test will run here
test.only('test 2', () => {}) //
})
仅用于()的别名:
增加一个 f。 但要小心ftest()不是一个别名! ! !
it.only()
fit()
describe.only()
fdescribe()
ftest() // WRONG ERROR !!! No such an alias SADLY!!!
jest --testPathIgnorePatterns=".*/__fixtures__/.*"
对于数组(多个 regex) :
有不同的方式:
# one regex with or operator `|`
jest --testPathIgnorePatterns=".*/__fixtures__/.*|<rootDir>/src/someDir/"
# paranthesis with spaces
jest --testPathIgnorePatterns="\(.*/__fixtures__/.* <rootDir>/src/someDir/\)"
# using the argument multiple times
jest --testPathIgnorePatterns=".*/__fixtures__/.*" --testPathIgnorePatterns="<rootDir>/src/someDir/"