eslint-plugin-jest
Version:
Eslint rules for Jest
56 lines (53 loc) • 1.51 kB
JavaScript
;
const _require = require('eslint'),
RuleTester = _require.RuleTester;
const rule = require('../prefer-todo');
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2015
}
});
ruleTester.run('prefer-todo', rule, {
valid: ['test.todo("i need to write this test");', 'test(obj)', 'fit("foo")', 'xit("foo")', 'test("stub", () => expect(1).toBe(1));', `
supportsDone && params.length < test.length
? done => test(...params, done)
: () => test(...params);
`],
invalid: [{
code: `test("i need to write this test");`,
errors: [{
messageId: 'todoOverUnimplemented'
}],
output: 'test.todo("i need to write this test");'
}, {
code: 'test(`i need to write this test`);',
errors: [{
messageId: 'todoOverUnimplemented'
}],
output: 'test.todo(`i need to write this test`);'
}, {
code: 'it("foo", function () {})',
errors: [{
messageId: 'todoOverEmpty'
}],
output: 'it.todo("foo")'
}, {
code: 'it("foo", () => {})',
errors: [{
messageId: 'todoOverEmpty'
}],
output: 'it.todo("foo")'
}, {
code: `test.skip("i need to write this test", () => {});`,
errors: [{
messageId: 'todoOverEmpty'
}],
output: 'test.todo("i need to write this test");'
}, {
code: `test.skip("i need to write this test", function() {});`,
errors: [{
messageId: 'todoOverEmpty'
}],
output: 'test.todo("i need to write this test");'
}]
});