Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ const assert = require("node:assert");
const SUPPORTED_TEST_IDENTIFIERS = new Set(["test", "asyncTest", "only"]);

const OLD_MODULE_HOOK_IDENTIFIERS = ["setup", "teardown"];
const NEW_MODULE_HOOK_IDENTIFIERS = ["beforeEach", "afterEach"];
const NEW_MODULE_HOOK_IDENTIFIERS = [
"before",
"beforeEach",
"afterEach",
"after",
];
const ALL_MODULE_HOOK_IDENTIFIERS = new Set([
...OLD_MODULE_HOOK_IDENTIFIERS,
...NEW_MODULE_HOOK_IDENTIFIERS,
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/rules/no-arrow-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ ruleTester.run("no-arrow-tests", rule, {
},
],
},
{
code: "QUnit.module('module', { before: () => {} });",
output: "QUnit.module('module', { before: function() {} });",
errors: [
{
messageId: "noArrowFunction",
type: "ArrowFunctionExpression",
},
],
},
{
code: "QUnit.module('module', { after: () => {} });",
output: "QUnit.module('module', { after: function() {} });",
errors: [
{
messageId: "noArrowFunction",
type: "ArrowFunctionExpression",
},
],
},
{
code: "module('module', { setup: () => {} });",
output: "module('module', { setup: function() {} });",
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/no-qunit-start-in-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ ruleTester.run("no-qunit-start-in-tests", rule, {
code: 'QUnit.module("module", { afterEach: function() { QUnit.start(); } });',
errors: [createError("afterEach hook")],
},
{
code: 'QUnit.module("module", { before: function() { QUnit.start(); } });',
errors: [createError("before hook")],
},
{
code: 'QUnit.module("module", { after: function() { QUnit.start(); } });',
errors: [createError("after hook")],
},
{
code: 'QUnit.module("module", { setup: function() { QUnit.start(); } });',
errors: [createError("setup hook")],
Expand Down
10 changes: 8 additions & 2 deletions tests/lib/rules/no-setup-teardown.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ ruleTester.run("no-setup-teardown", rule, {
// afterEach
"QUnit.module('Module', { afterEach: function () {} });",

// both
"QUnit.module('Module', { beforeEach: function () {}, afterEach: function () {} });",
// before
"QUnit.module('Module', { before: function () {} });",

// after
"QUnit.module('Module', { after: function () {} });",

// all
"QUnit.module('Module', { before: function () {}, beforeEach: function () {}, afterEach: function () {}, after: function () {} });",

// other property names are not reported
"QUnit.module('Module', { foo: function () {} });",
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/resolve-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ ruleTester.run("resolve-async", rule, {
code: "QUnit.module('name', { teardown: function () { QUnit.stop(); } });",
errors: [createNeedStartCallsMessage("Property")],
},
{
code: "QUnit.module('name', { before: function () { QUnit.stop(); } });",
errors: [createNeedStartCallsMessage("Property")],
},
{
code: "QUnit.module('name', { beforeEach: function () { QUnit.stop(); } });",
errors: [createNeedStartCallsMessage("Property")],
Expand All @@ -203,6 +207,10 @@ ruleTester.run("resolve-async", rule, {
code: "QUnit.module('name', { afterEach: function () { QUnit.stop(); } });",
errors: [createNeedStartCallsMessage("Property")],
},
{
code: "QUnit.module('name', { after: function () { QUnit.stop(); } });",
errors: [createNeedStartCallsMessage("Property")],
},

// Multiple start() calls needed
{
Expand Down