1
1
mirror of https://github.com/theoludwig/eslint-config-conventions.git synced 2024-11-09 22:08:37 +01:00

test: easier to debug in case of failures

This commit is contained in:
Théo LUDWIG 2024-09-18 00:29:14 +02:00
parent a03e2bd109
commit 921aacdc9b
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B

View File

@ -16,8 +16,12 @@ test("ensure we validate correctly JavaScript files", async () => {
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(noErrors?.errorCount, 0)
assert.strictEqual(withErrors?.errorCount, 3)
assert.strictEqual(noErrors?.errorCount, 0, JSON.stringify(noErrors, null, 2))
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
test("ensure we do not use deprecated rules", async () => {
@ -27,8 +31,16 @@ test("ensure we do not use deprecated rules", async () => {
const [typescriptLintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors.ts",
)
assert.strictEqual(javascriptLintResult.usedDeprecatedRules.length, 0)
assert.strictEqual(typescriptLintResult.usedDeprecatedRules.length, 0)
assert.strictEqual(
javascriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(javascriptLintResult, null, 2),
)
assert.strictEqual(
typescriptLintResult.usedDeprecatedRules.length,
0,
JSON.stringify(typescriptLintResult, null, 2),
)
})
test("ensure we validate correctly TypeScript files", async () => {
@ -38,20 +50,32 @@ test("ensure we validate correctly TypeScript files", async () => {
const [withErrors] = await eslint.lintFiles(
"test/fixtures/javascript-with-errors.js",
)
assert.strictEqual(noErrors?.errorCount, 0)
assert.strictEqual(withErrors?.errorCount, 3)
assert.strictEqual(noErrors?.errorCount, 0, JSON.stringify(noErrors, null, 2))
assert.strictEqual(
withErrors?.errorCount,
3,
JSON.stringify(withErrors, null, 2),
)
})
test("ensure we allow top-level await", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/top-level-await.mjs",
)
assert.strictEqual(lintResult?.errorCount, 0)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})
test("ensure we allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
const [lintResult] = await eslint.lintFiles(
"test/fixtures/typescript-no-errors-ignore-promise.ts",
)
assert.strictEqual(lintResult?.errorCount, 0)
assert.strictEqual(
lintResult?.errorCount,
0,
JSON.stringify(lintResult, null, 2),
)
})