Add eslint-plugin-jest (#11119)

* chore: add eslint-plugin-jest

* chore: update test sources

* chore: suppress preset-env debug log when linting
This commit is contained in:
Huáng Jùnliàng
2020-02-11 00:11:32 +09:00
committed by GitHub
parent a4d5c6253e
commit 865d5155c2
12 changed files with 89 additions and 20 deletions

View File

@@ -94,8 +94,8 @@ describe("option-manager", () => {
expect(() => {
loadOptions({
plugins: [[plugin, null]],
}).toThrow(/.plugins[0][1] must be an object, false, or undefined/);
});
});
}).toThrow(".plugins[0][1] must be an object, false, or undefined");
expect(calls).toEqual([]);
});
@@ -140,8 +140,8 @@ describe("option-manager", () => {
expect(() => {
loadOptions({
presets: [preset, preset],
}).toThrow(/Duplicate plugin\/preset detected/);
});
});
}).toThrow(/Duplicate plugin\/preset detected/);
expect(calls).toEqual([]);
});

View File

@@ -33,7 +33,7 @@ describe("'decoratorsBeforeExport' option", function() {
expect(makeParser("", { decoratorsBeforeExport: "before" })).toThrow();
});
test.skip("is required", function() {
test("is required", function() {
expect(makeParser("", { legacy: false })).toThrow(/decoratorsBeforeExport/);
});

View File

@@ -219,7 +219,7 @@ describe("@babel/template", function() {
});
});
describe.only(".syntacticPlaceholders", () => {
describe(".syntacticPlaceholders", () => {
it("works in function body", () => {
const output = template(`function f() %%A%%`)({
A: t.blockStatement([]),
@@ -302,12 +302,10 @@ describe("@babel/template", function() {
});
it("replaces identifiers", () => {
expect(() => {
const output = template(`FOO`)({
FOO: t.numericLiteral(1),
});
expect(generator(output).code).toMatchInlineSnapshot(`"1;"`);
const output = template(`FOO`)({
FOO: t.numericLiteral(1),
});
expect(generator(output).code).toMatchInlineSnapshot(`"1;"`);
});
it("doesn't mix placeholder styles", () => {

View File

@@ -4,8 +4,12 @@ exports[`scope duplicate bindings catch const 1`] = `"Duplicate declaration \\"e
exports[`scope duplicate bindings catch let 1`] = `"Duplicate declaration \\"e\\""`;
exports[`scope duplicate bindings global class/const 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global class/function 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global class/let 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global const/class 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global const/const 1`] = `"Duplicate declaration \\"foo\\""`;
@@ -16,10 +20,18 @@ exports[`scope duplicate bindings global const/let 1`] = `"Duplicate declaration
exports[`scope duplicate bindings global const/var 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global function/class 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global function/let 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global let/class 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global let/const 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global let/function 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global let/let 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global let/var 1`] = `"Duplicate declaration \\"foo\\""`;
exports[`scope duplicate bindings global var/let 1`] = `"Duplicate declaration \\"foo\\""`;

View File

@@ -422,7 +422,11 @@ describe("scope", () => {
}
});
/*if (kind1 !== kind2) {
if (kind1 !== kind2) {
//todo: remove the if whitelist
if (kind1 === "const" && (kind2 === "function" || kind2 === "var")) {
continue;
}
it(`${kind2}/${kind1}`, () => {
const ast = createAST(kind2, kind1);
@@ -432,7 +436,7 @@ describe("scope", () => {
expect(() => getPath(ast)).toThrowErrorMatchingSnapshot();
}
});
}*/
}
}
});
});

View File

@@ -196,7 +196,8 @@ describe("traverse", function() {
expect(skipped).toBe(true);
});
// Skipped: see the comment in the `NodePath.requque` method.
// Skipped: see the comment in the `NodePath.requeue` method.
// eslint-disable-next-line jest/no-disabled-tests
it.skip("skipped and requeued paths should be visited", function() {
const ast = parse("id");