Skip to content

Commit

Permalink
chore: improve test coverage to 100% (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel authored Jun 26, 2024
1 parent f6edc4a commit 8173f01
Show file tree
Hide file tree
Showing 83 changed files with 2,096 additions and 493 deletions.
22 changes: 2 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"ignoreRegExpLiterals": true
}
],
"prefer-regex-literals": "error",
"eol-last": ["error", "always"],
"import/no-default-export": "error",
"eqeqeq": [2, "always"],
"no-var": 2,
"block-scoped-var": 2,
"curly": 2,
"no-async-promise-executor": "off",
"no-bitwise": [2, { "allow": ["~"] }],
"no-duplicate-imports": [2, { "includeExports": true }],
Expand Down Expand Up @@ -71,31 +73,11 @@
"files": ["*.ts"],
"rules": {
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/quotes": [
"error",
"single",
{ "avoidEscape": true, "allowTemplateLiterals": true }
],
"@typescript-eslint/no-empty-function": [
"error",
{ "allow": ["arrowFunctions"] }
]
}
},
{
"files": ["*.js"],
"parserOptions": {
"project": null
},
"rules": {
"semi": ["error", "always"],
"quotes": [
"error",
"single",
{ "avoidEscape": true, "allowTemplateLiterals": true }
],
"no-unused-vars": 2
}
}
],
"settings": {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules
/.temp
/test-src
/test-tests
/test-before-and-after-each.json
8 changes: 6 additions & 2 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const test = () => {
};

for (const [name, result] of results) {
if (name === 'Poku (Local)') continue;
if (name === 'Poku (Local)') {
continue;
}

const expectedRatio = tolerancesPerTester[name];
const actualRatio = pokuResult.opsPerSec / result.opsPerSec;
Expand Down Expand Up @@ -71,7 +73,9 @@ suite

console.log(`\n🚀 Fastest is \x1b[1m${fatest}\x1b[0m\n`);

if (!/^Poku/.test(fatest)) process.exit(1);
if (!/^Poku/.test(fatest)) {
process.exit(1);
}

test();
})
Expand Down
95 changes: 95 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"files": {
"ignore": [
"node_modules",
"lib",
"ci",
"coverage",
"website",
"fixtures",
"benchmark"
]
},
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"all": true,
"complexity": {
"all": true,
"noExcessiveCognitiveComplexity": "off"
},
"a11y": {
"all": true
},
"correctness": {
"all": true,
"noNodejsModules": "off"
},
"nursery": {
"all": true,
"useImportRestrictions": "off",
"noConsole": "off",
"noMisplacedAssertion": "off"
},
"performance": {
"all": true
},
"security": {
"all": true
},
"suspicious": {
"all": true,
"noAsyncPromiseExecutor": "off",
"noEmptyBlockStatements": "off",
"noConsoleLog": "off"
},
"style": {
"all": true,
"noNonNullAssertion": "off",
"useNamingConvention": "off",
"useNodeAssertStrict": "off",
"noNamespaceImport": "off",
"useForOf": "off"
}
}
},
"javascript": {
"globals": ["BufferEncoding"]
},
"overrides": [
{
"include": ["test", "tools"],
"linter": {
"rules": {
"nursery": {
"useTopLevelRegex": "off"
}
}
}
},
{
"include": ["src/polyfills"],
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "off"
}
}
}
},
{
"include": ["src/index.ts"],
"linter": {
"rules": {
"performance": {
"noBarrelFile": "off"
}
}
}
}
]
}
13 changes: 13 additions & 0 deletions fixtures/before-after-each/integration.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const fs = require('node:fs');
const path = require('node:path');

const jsonFilePath = path.resolve('./test-before-and-after-each.json');

const data = fs.readFileSync(jsonFilePath, 'utf-8');
const json = JSON.parse(data);

json.value += 1;

fs.writeFileSync(jsonFilePath, JSON.stringify(json));
2 changes: 1 addition & 1 deletion fixtures/fail/exit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import process from 'node:process';

console.log(123);
console.log('Failure Fixture');
process.exit(1);
2 changes: 1 addition & 1 deletion fixtures/success/exit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import process from 'node:process';

console.log(123);
console.log('Sucess Fixture');
process.exit(0);
Loading

0 comments on commit 8173f01

Please sign in to comment.