Skip to content

Latest commit

 

History

History
55 lines (34 loc) · 1.77 KB

no-test-expect-argument.md

File metadata and controls

55 lines (34 loc) · 1.77 KB

Disallow the expect argument in QUnit.test (qunit/no-test-expect-argument)

💼 This rule is enabled in the ✅ recommended config.

QUnit 2.0 is deprecating expect counts as the second argument of QUnit.test. Users are expected to use assert.expect() instead.

Rule Details

The following patterns are considered warnings:

test("test name", 0, function () { });

QUnit.test("test name", 0, function () { });

asyncTest("test name", 0, function () { });

QUnit.asyncTest("test name", 0, function () { });

The following patterns are not warnings:

// No expect call at all
test("test name", function () { });
QUnit.test("test name", function () { });
asyncTest("test name", function () { });
QUnit.asyncTest("test name", function () { });

// Global expect() is not checked by this rule
test("test name", function () { expect(0); });
QUnit.test("test name", function () { expect(0); });
asyncTest("test name", function () { expect(0); });
QUnit.asyncTest("test name", function () { expect(0); });

// assert.expect() is best
test("test name", function (assert) { assert.expect(0); });
QUnit.test("test name", function (assert) { assert.expect(0); });
asyncTest("test name", function (assert) { assert.expect(0); });
QUnit.asyncTest("test name", function (assert) { assert.expect(0); });

When Not To Use It

This rule can be safely disabled if you want to tolerate an expect argument in QUnit.test(), especially if your codebase does not use QUnit 2.0 syntax yet.

Further Reading