Skip to content

Commit

Permalink
🐛 Support TDD interface in no-setup-in-describe
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Nov 22, 2019
1 parent b9b5531 commit e8e2b62
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/util/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const describeAliases = [
'context', 'xcontext', 'context.only', 'context.skip',
'suite', 'xsuite', 'suite.only', 'suite.skip'
];
const hooks = [ 'before', 'after', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll' ];
const hooks = [
'before', 'after', 'beforeEach', 'afterEach', 'beforeAll', 'afterAll',
'setup', 'teardown', 'suiteSetup', 'suiteTeardown'
];
const suiteConfig = [ 'timeout', 'slow', 'retries' ];
const testCaseNames = [
'it', 'it.only', 'it.skip', 'xit',
Expand Down
11 changes: 11 additions & 0 deletions test/rules/no-setup-in-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ ruleTester.run('no-setup-in-describe', rule, {
'describe("", function () { function a() { b(); }; it(); })',
'describe("", function () { function a() { b.c; }; it(); })',
'describe("", function () { afterEach(function() { b(); }); it(); })',
'suite("", function () { teardown(function() { b(); }); test(); })',
'suite("", function () { suiteTeardown(function() { b(); }); test(); })',
'suite("", function () { setup(function() { b(); }); test(); })',
'suite("", function () { suiteSetup(function() { b(); }); test(); })',
{
code: 'describe("", function () { before(() => { b(); }); it(); })',
parserOptions: { ecmaVersion: 6 }
Expand Down Expand Up @@ -80,6 +84,13 @@ ruleTester.run('no-setup-in-describe', rule, {

invalid: [
{
code: 'suite("", function () { a(); });',
errors: [ {
message: 'Unexpected function call in describe block.',
line: 1,
column: 25
} ]
}, {
code: 'describe("", function () { a(); });',
errors: [ {
message: 'Unexpected function call in describe block.',
Expand Down

0 comments on commit e8e2b62

Please sign in to comment.