Skip to content

Commit

Permalink
Better test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Dec 27, 2023
1 parent f1c28a5 commit 56d3fc4
Show file tree
Hide file tree
Showing 9 changed files with 9,569 additions and 9,491 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {

overrides: [
{
files: ["src/**/__tests__/**"],
files: ["test/**"],

// Special config for test files
rules: {
Expand Down
18,756 changes: 9,413 additions & 9,343 deletions package-lock.json

Large diffs are not rendered by default.

133 changes: 67 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
{
"name": "itertools",
"version": "2.1.2",
"description": "A JavaScript port of Python's awesome itertools standard library",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/nvie/itertools.git"
},
"author": "Vincent Driessen",
"homepage": "https://github.com/nvie/itertools#readme",
"bugs": {
"url": "https://github.com/nvie/itertools/issues"
},
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"default": "./dist/index.js"
}
}
},
"scripts": {
"actually-prepublish": "echo \"\\n\\nPlease run \\`bin/publish.sh <options>\\` instead.\\n\\n\" && exit 2",
"build": "tsup",
"clean": "rimraf dist",
"format": "prettier --write src/",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint --report-unused-disable-directives src/",
"lint:prettier": "prettier --list-different src/",
"lint:package": "publint --strict && attw --pack",
"prepublish": "in-publish && npm run actually-prepublish || not-in-publish",
"test": "vitest run --coverage"
},
"files": [
"dist/",
"LICENSE",
"README.md"
],
"keywords": [
"itertool",
"itertools",
"node-itertools"
],
"devDependencies": {
"@arethetypeswrong/cli": "^0.4.2",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@vitest/coverage-istanbul": "^0.32.4",
"eslint": "^8.44.0",
"fast-check": "^3.8.0",
"in-publish": "^2.0.1",
"prettier": "^3.1.1",
"publint": "^0.1.15",
"tsup": "^7.1.0",
"typescript": "^4.3.5",
"vitest": "^0.32.3"
},
"githubUrl": "https://github.com/nvie/itertools",
"sideEffects": false
"name": "itertools",
"version": "2.1.2",
"description": "A JavaScript port of Python's awesome itertools standard library",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/nvie/itertools.git"
},
"author": "Vincent Driessen",
"homepage": "https://github.com/nvie/itertools#readme",
"bugs": {
"url": "https://github.com/nvie/itertools/issues"
},
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"default": "./dist/index.js"
}
}
},
"scripts": {
"actually-prepublish": "echo \"\\n\\nPlease run \\`bin/publish.sh <options>\\` instead.\\n\\n\" && exit 2",
"build": "tsup",
"clean": "rimraf dist",
"format": "prettier --write src/ test/",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint --report-unused-disable-directives src/ test/",
"lint:prettier": "prettier --list-different src/ test/",
"lint:package": "publint --strict && attw --pack",
"prepublish": "in-publish && npm run actually-prepublish || not-in-publish",
"test": "vitest run --coverage"
},
"files": [
"dist/",
"LICENSE",
"README.md"
],
"keywords": [
"itertool",
"itertools",
"node-itertools"
],
"devDependencies": {
"@arethetypeswrong/cli": "^0.4.2",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@vitest/coverage-istanbul": "^0.32.4",
"eslint": "^8.44.0",
"fast-check": "^3.8.0",
"in-publish": "^2.0.1",
"prettier": "^3.1.1",
"publint": "^0.1.15",
"tsup": "^7.1.0",
"typescript": "^4.3.5",
"vite-tsconfig-paths": "^4.2.2",
"vitest": "^0.32.3"
},
"githubUrl": "https://github.com/nvie/itertools",
"sideEffects": false
}
4 changes: 2 additions & 2 deletions src/__tests__/builtins.test.ts → test/builtins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
sum,
zip,
zip3,
} from "../builtins";
import { first } from "../custom";
} from "~/builtins";
import { first } from "~/custom";

const isEven = (n: number) => n % 2 === 0;

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/custom.test.ts → test/custom.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import { compact, compactObject, flatmap } from "../custom";
import { repeat } from "../itertools";
import { compact, compactObject, flatmap } from "~/custom";
import { repeat } from "~/itertools";

describe("compact", () => {
it("compact w/ empty list", () => {
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/itertools.test.ts → test/itertools.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { all, range } from "../builtins";
import { all, range } from "~/builtins";
import {
chain,
compress,
Expand All @@ -16,8 +16,8 @@ import {
zipLongest,
zipLongest3,
zipMany,
} from "../itertools";
import { take } from "../more-itertools";
} from "~/itertools";
import { take } from "~/more-itertools";

const isEven = (x: number) => x % 2 === 0;
const isPositive = (x: number) => x >= 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
import { range } from "../builtins";
import { find, first } from "../custom";
import { range } from "~/builtins";
import { find, first } from "~/custom";
import {
chunked,
flatten,
Expand All @@ -12,7 +12,7 @@ import {
take,
uniqueEverseen,
uniqueJustseen,
} from "../more-itertools";
} from "~/more-itertools";
import * as fc from "fast-check";

const isEven = (x: number) => x % 2 === 0;
Expand Down
125 changes: 65 additions & 60 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,70 +1,75 @@
{
"compilerOptions": {
"noEmit": true,
"strict": true,
"target": "es2015",
"lib": ["es6"],
"compilerOptions": {
"noEmit": true,
"strict": true,
"target": "es2015",
"lib": ["es6"],

/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"module": "commonjs", // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"module": "commonjs", // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Strict Type-Checking Options */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["./src/"]
/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"paths": {
"~": ["./src"],
"~/*": ["./src/*"]
}
},
"include": ["src", "test"],
"exclude": ["node_modules", "dist"]
}
24 changes: 13 additions & 11 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { defineConfig } from 'vitest/config';
import { defineConfig } from "vitest/config";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
test: {
coverage: {
provider: 'istanbul',
reporter: ['text', 'html'],
plugins: [tsconfigPaths()],
test: {
coverage: {
provider: "istanbul",
reporter: ["text", "html"],

// Require 100% test coverage
lines: 100,
functions: 100,
statements: 100,
branches: 100,
},
// Require 100% test coverage
lines: 100,
functions: 100,
statements: 100,
branches: 100,
},
},
});

0 comments on commit 56d3fc4

Please sign in to comment.