From 185d4863ed4352149bef44ab01b45a82eeaa1d61 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 3 Apr 2023 10:35:40 +0100 Subject: [PATCH 1/3] Added CI checks for snapshotting the correct errors --- scripts/tests/__snapshots__/tsc.test.ts.snap | 164 +++++++++ scripts/tests/package-lock.json | 351 +++++++++++++++++++ scripts/tests/package.json | 5 + scripts/tests/tsc.test.ts | 32 ++ scripts/tests/vite.config.ts | 9 + vite.config.ts | 2 +- 6 files changed, 562 insertions(+), 1 deletion(-) create mode 100644 scripts/tests/__snapshots__/tsc.test.ts.snap create mode 100644 scripts/tests/package-lock.json create mode 100644 scripts/tests/package.json create mode 100644 scripts/tests/tsc.test.ts create mode 100644 scripts/tests/vite.config.ts diff --git a/scripts/tests/__snapshots__/tsc.test.ts.snap b/scripts/tests/__snapshots__/tsc.test.ts.snap new file mode 100644 index 00000000..bdf0410f --- /dev/null +++ b/scripts/tests/__snapshots__/tsc.test.ts.snap @@ -0,0 +1,164 @@ +// Vitest Snapshot v1 + +exports[`tsc > In file 01-number.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/01-number.problem.ts(3,31): error TS7006: Parameter 'a' implicitly has an 'any' type. +../../src/01-number.problem.ts(3,34): error TS7006: Parameter 'b' implicitly has an 'any' type. +," +`; + +exports[`tsc > In file 01-number.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 02-object-param.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/02-object-param.problem.ts(3,31): error TS7006: Parameter 'params' implicitly has an 'any' type. +," +`; + +exports[`tsc > In file 02-object-param.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 02-object-param.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 02-object-param.solution.3.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 03-optional-properties.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/03-optional-properties.problem.ts(11,24): error TS2345: Argument of type '{ first: string; }' is not assignable to parameter of type '{ first: string; last: string; }'. + Property 'last' is missing in type '{ first: string; }' but required in type '{ first: string; last: string; }'. +," +`; + +exports[`tsc > In file 03-optional-properties.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 04-optional-params.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/04-optional-params.problem.ts(11,16): error TS2554: Expected 2 arguments, but got 1. +," +`; + +exports[`tsc > In file 04-optional-params.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 05-assigning-types-to-variables.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/05-assigning-types-to-variables.problem.ts(21,20): error TS2345: Argument of type '{}' is not assignable to parameter of type 'User'. + Type '{}' is missing the following properties from type 'User': id, firstName, lastName, isAdmin +," +`; + +exports[`tsc > In file 05-assigning-types-to-variables.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 06-unions.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/06-unions.problem.ts(18,3): error TS2578: Unused '@ts-expect-error' directive. +," +`; + +exports[`tsc > In file 06-unions.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 07-arrays.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/07-arrays.problem.ts(19,3): error TS2739: Type '{ id: number; title: string; }[]' is missing the following properties from type 'Post': id, title +," +`; + +exports[`tsc > In file 07-arrays.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 07-arrays.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 08-function-return-type-annotations.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/08-function-return-type-annotations.problem.ts(27,15): error TS2339: Property 'id' does not exist on type '{}'. +../../src/08-function-return-type-annotations.problem.ts(28,15): error TS2339: Property 'firstName' does not exist on type '{}'. +../../src/08-function-return-type-annotations.problem.ts(29,15): error TS2339: Property 'lastName' does not exist on type '{}'. +../../src/08-function-return-type-annotations.problem.ts(30,15): error TS2339: Property 'role' does not exist on type '{}'. +../../src/08-function-return-type-annotations.problem.ts(32,15): error TS2339: Property 'posts' does not exist on type '{}'. +../../src/08-function-return-type-annotations.problem.ts(33,15): error TS2339: Property 'posts' does not exist on type '{}'. +," +`; + +exports[`tsc > In file 08-function-return-type-annotations.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 09-promises.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/09-promises.problem.ts(12,45): error TS1055: Type 'LukeSkywalker' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. +," +`; + +exports[`tsc > In file 09-promises.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 09-promises.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 09-promises.solution.3.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 10-set.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/10-set.problem.ts(15,3): error TS2578: Unused '@ts-expect-error' directive. +../../src/10-set.problem.ts(22,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. +," +`; + +exports[`tsc > In file 10-set.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 11-record.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/11-record.problem.ts(7,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. + No index signature with a parameter of type 'string' was found on type '{}'. +../../src/11-record.problem.ts(11,12): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. + No index signature with a parameter of type 'string' was found on type '{}'. +../../src/11-record.problem.ts(26,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. + Property '123' does not exist on type '{}'. +../../src/11-record.problem.ts(35,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. + Property '123' does not exist on type '{}'. +," +`; + +exports[`tsc > In file 11-record.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 11-record.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 11-record.solution.3.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 12-typeof-narrowing.problem.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 12-typeof-narrowing.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 13-catch-blocks.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/13-catch-blocks.problem.ts(9,12): error TS2571: Object is of type 'unknown'. +," +`; + +exports[`tsc > In file 13-catch-blocks.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 13-catch-blocks.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 13-catch-blocks.solution.3.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 14-extends.problem.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 14-extends.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 15-intersection.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/15-intersection.problem.ts(34,13): error TS2571: Object is of type 'unknown'. +," +`; + +exports[`tsc > In file 15-intersection.solution.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 16-omit-and-pick.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/16-omit-and-pick.problem.ts(16,22): error TS2344: Type 'false' does not satisfy the constraint 'true'. +," +`; + +exports[`tsc > In file 16-omit-and-pick.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 16-omit-and-pick.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 17-function-types.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/17-function-types.problem.ts(8,5): error TS2571: Object is of type 'unknown'. +../../src/17-function-types.problem.ts(12,5): error TS2571: Object is of type 'unknown'. +../../src/17-function-types.problem.ts(16,14): error TS7006: Parameter 'isFocused' implicitly has an 'any' type. +../../src/17-function-types.problem.ts(19,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. +," +`; + +exports[`tsc > In file 17-function-types.solution.1.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 17-function-types.solution.2.ts, TS errors should match snapshot 1`] = `""`; + +exports[`tsc > In file 18-function-types-with-promises.problem.ts, TS errors should match snapshot 1`] = ` +",../../src/18-function-types-with-promises.problem.ts(13,32): error TS2571: Object is of type 'unknown'. +../../src/18-function-types-with-promises.problem.ts(15,22): error TS2571: Object is of type 'unknown'. +../../src/18-function-types-with-promises.problem.ts(23,12): error TS7006: Parameter 'id' implicitly has an 'any' type. +," +`; + +exports[`tsc > In file 18-function-types-with-promises.solution.ts, TS errors should match snapshot 1`] = `""`; diff --git a/scripts/tests/package-lock.json b/scripts/tests/package-lock.json new file mode 100644 index 00000000..544795d7 --- /dev/null +++ b/scripts/tests/package-lock.json @@ -0,0 +1,351 @@ +{ + "name": "tests", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "fast-glob": "^3.2.12" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + } + }, + "dependencies": { + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + } + }, + "fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "requires": { + "reusify": "^1.0.4" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "requires": { + "queue-microtask": "^1.2.2" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + } + } +} diff --git a/scripts/tests/package.json b/scripts/tests/package.json new file mode 100644 index 00000000..7a51e6b1 --- /dev/null +++ b/scripts/tests/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "fast-glob": "^3.2.12" + } +} diff --git a/scripts/tests/tsc.test.ts b/scripts/tests/tsc.test.ts new file mode 100644 index 00000000..c1af9542 --- /dev/null +++ b/scripts/tests/tsc.test.ts @@ -0,0 +1,32 @@ +import fg from "fast-glob"; +import path from "path"; +import { describe, expect, it } from "vitest"; +import { execSync } from "child_process"; + +const srcFolder = path.resolve(__dirname, "../../src"); + +const allFiles = path.resolve(srcFolder, "*{problem,solution,explainer}*.ts"); + +const toRelativeFilename = (file: string) => { + return path.relative(srcFolder, file); +}; + +describe("tsc", async () => { + const files = await fg(allFiles); + + it.each(files.map(toRelativeFilename))( + "In file %s, TS errors should match snapshot", + (file) => { + const resolvedFile = path.join(srcFolder, file); + let result: string; + + try { + result = execSync(`tsc "${resolvedFile}" --noEmit --strict`).toString(); + } catch (error) { + result = error.output.toString(); + } + + expect(result).toMatchSnapshot(); + }, + ); +}); diff --git a/scripts/tests/vite.config.ts b/scripts/tests/vite.config.ts new file mode 100644 index 00000000..863de505 --- /dev/null +++ b/scripts/tests/vite.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + setupFiles: ["../setup.ts"], + passWithNoTests: true, + teardownTimeout: 5000, + }, +}); diff --git a/vite.config.ts b/vite.config.ts index 3ba69064..7ee4b71c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from "vite"; +import { defineConfig } from "vitest/config"; export default defineConfig({ test: { From 2b5de942695bc700043331465be7c2bd13668fe5 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 3 Apr 2023 11:02:39 +0100 Subject: [PATCH 2/3] Added GH workflow --- .github/workflows/main.yml | 17 + package-lock.json | 886 +++++++++++++++++-- package.json | 3 +- scripts/tests/__snapshots__/all.test.ts.snap | 762 ++++++++++++++++ scripts/tests/__snapshots__/tsc.test.ts.snap | 164 ---- scripts/tests/all.test.ts | 39 + scripts/tests/cleanVitestOutput.ts | 48 + scripts/tests/package-lock.json | 351 -------- scripts/tests/package.json | 5 - scripts/tests/tsc.test.ts | 32 - vite.config.ts | 4 +- 11 files changed, 1686 insertions(+), 625 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 scripts/tests/__snapshots__/all.test.ts.snap delete mode 100644 scripts/tests/__snapshots__/tsc.test.ts.snap create mode 100644 scripts/tests/all.test.ts create mode 100644 scripts/tests/cleanVitestOutput.ts delete mode 100644 scripts/tests/package-lock.json delete mode 100644 scripts/tests/package.json delete mode 100644 scripts/tests/tsc.test.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c32c8ae6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,17 @@ +name: CI +on: + push: + branches: + - "**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16.x + + - run: npm install --frozen-lockfile + - run: npm run ci diff --git a/package-lock.json b/package-lock.json index 00466dc2..3df67c6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "cross-env": "^7.0.3", "cross-fetch": "^3.1.5", "typescript": "^4.8.3", - "vitest": "^0.21.1" + "vitest": "^0.29.8" } }, "node_modules/@types/body-parser": { @@ -33,11 +33,10 @@ } }, "node_modules/@types/chai": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", - "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", - "dev": true, - "license": "MIT" + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==", + "dev": true }, "node_modules/@types/chai-subset": { "version": "1.3.3", @@ -109,6 +108,49 @@ "@types/node": "*" } }, + "node_modules/@vitest/expect": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.29.8.tgz", + "integrity": "sha512-xlcVXn5I5oTq6NiZSY3ykyWixBxr5mG8HYtjvpgg6KaqHm0mvhX18xuwl5YGxIRNt/A5jidd7CWcNHrSvgaQqQ==", + "dev": true, + "dependencies": { + "@vitest/spy": "0.29.8", + "@vitest/utils": "0.29.8", + "chai": "^4.3.7" + } + }, + "node_modules/@vitest/runner": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.29.8.tgz", + "integrity": "sha512-FzdhnRDwEr/A3Oo1jtIk/B952BBvP32n1ObMEb23oEJNO+qO5cBet6M2XWIDQmA7BDKGKvmhUf2naXyp/2JEwQ==", + "dev": true, + "dependencies": { + "@vitest/utils": "0.29.8", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + } + }, + "node_modules/@vitest/spy": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.29.8.tgz", + "integrity": "sha512-VdjBe9w34vOMl5I5mYEzNX8inTxrZ+tYUVk9jxaZJmHFwmDFC/GV3KBFTA/JKswr3XHvZL+FE/yq5EVhb6pSAw==", + "dev": true, + "dependencies": { + "tinyspy": "^1.0.2" + } + }, + "node_modules/@vitest/utils": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.29.8.tgz", + "integrity": "sha512-qGzuf3vrTbnoY+RjjVVIBYfuWMjn3UMUqyQtdGNZ6ZIIyte7B37exj6LaVkrZiUTvzSadVvO/tJm8AEgbGCBPg==", + "dev": true, + "dependencies": { + "cli-truncate": "^3.1.0", + "diff": "^5.1.0", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + } + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -122,6 +164,48 @@ "node": ">= 0.6" } }, + "node_modules/acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -147,7 +231,6 @@ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -208,6 +291,15 @@ "node": ">= 0.8" } }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -222,15 +314,14 @@ } }, "node_modules/chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", "dev": true, - "license": "MIT", "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.2", - "deep-eql": "^3.0.1", + "deep-eql": "^4.1.2", "get-func-name": "^2.0.0", "loupe": "^2.3.1", "pathval": "^1.1.1", @@ -245,7 +336,6 @@ "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -278,6 +368,22 @@ "fsevents": "~2.3.2" } }, + "node_modules/cli-truncate": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz", + "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==", + "dev": true, + "dependencies": { + "slice-ansi": "^5.0.0", + "string-width": "^5.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -366,16 +472,15 @@ } }, "node_modules/deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "dev": true, - "license": "MIT", "dependencies": { "type-detect": "^4.0.0" }, "engines": { - "node": ">=0.12" + "node": ">=6" } }, "node_modules/depd": { @@ -397,12 +502,33 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/diff": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "license": "MIT" }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -593,7 +719,6 @@ "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -726,6 +851,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", + "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -755,6 +892,12 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "node_modules/jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "node_modules/local-pkg": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.2.tgz", @@ -769,11 +912,10 @@ } }, "node_modules/loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", "dev": true, - "license": "MIT", "dependencies": { "get-func-name": "^2.0.0" } @@ -835,6 +977,18 @@ "node": ">= 0.6" } }, + "node_modules/mlly": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.2.0.tgz", + "integrity": "sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.2", + "ufo": "^1.1.1" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -915,6 +1069,21 @@ "node": ">= 0.8" } }, + "node_modules/p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -946,12 +1115,17 @@ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==", "license": "MIT" }, + "node_modules/pathe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.0.tgz", + "integrity": "sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==", + "dev": true + }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true, - "license": "MIT", "engines": { "node": "*" } @@ -976,6 +1150,17 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pkg-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.2.tgz", + "integrity": "sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==", + "dev": true, + "dependencies": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.1.1", + "pathe": "^1.1.0" + } + }, "node_modules/postcss": { "version": "8.4.16", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", @@ -1001,6 +1186,20 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1053,6 +1252,12 @@ "node": ">= 0.8" } }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -1208,6 +1413,49 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, + "node_modules/slice-ansi": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", + "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.0.0", + "is-fullwidth-code-point": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/slice-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", @@ -1218,6 +1466,12 @@ "node": ">=0.10.0" } }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -1227,6 +1481,68 @@ "node": ">= 0.8" } }, + "node_modules/std-env": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.2.tgz", + "integrity": "sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==", + "dev": true + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -1240,20 +1556,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tinybench": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.4.0.tgz", + "integrity": "sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==", + "dev": true + }, "node_modules/tinypool": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.2.4.tgz", - "integrity": "sha512-Vs3rhkUH6Qq1t5bqtb816oT+HeJTXfwt2cbPH17sWHIYKTotQIFPk3tf2fgqRrVyMDVOc1EnPgzIxfIulXVzwQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.4.0.tgz", + "integrity": "sha512-2ksntHOKf893wSAH4z/+JbPpi92esw8Gn9N2deXX+B0EO92hexAVI9GIZZPx7P5aYo5KULfeOSt3kMOmSOy6uA==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/tinyspy": { - "version": "1.0.0", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-1.1.1.tgz", + "integrity": "sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==", "dev": true, - "license": "MIT", "engines": { "node": ">=14.0.0" } @@ -1292,7 +1614,6 @@ "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true, - "license": "MIT", "engines": { "node": ">=4" } @@ -1323,6 +1644,12 @@ "node": ">=4.2.0" } }, + "node_modules/ufo": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.1.tgz", + "integrity": "sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==", + "dev": true + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -1390,22 +1717,82 @@ } } }, + "node_modules/vite-node": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.8.tgz", + "integrity": "sha512-b6OtCXfk65L6SElVM20q5G546yu10/kNrhg08afEoWlFRJXFq9/6glsvSVY+aI6YeC1tu2TtAqI2jHEQmOmsFw==", + "dev": true, + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.1.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": ">=v14.16.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/vite-node/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/vite-node/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/vitest": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.21.1.tgz", - "integrity": "sha512-WBIxuFmIDPuK47GO6Lu9eNeRMqHj/FWL3dk73OHH3eyPPWPiu+UB3QHLkLK2PEggCqJW4FaWoWg8R68S7p9+9Q==", + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.29.8.tgz", + "integrity": "sha512-JIAVi2GK5cvA6awGpH0HvH/gEG9PZ0a/WoxdiV3PmqK+3CjQMf8c+J/Vhv4mdZ2nRyXFw66sAg6qz7VNkaHfDQ==", "dev": true, - "license": "MIT", "dependencies": { - "@types/chai": "^4.3.3", + "@types/chai": "^4.3.4", "@types/chai-subset": "^1.3.3", "@types/node": "*", - "chai": "^4.3.6", + "@vitest/expect": "0.29.8", + "@vitest/runner": "0.29.8", + "@vitest/spy": "0.29.8", + "@vitest/utils": "0.29.8", + "acorn": "^8.8.1", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", "debug": "^4.3.4", "local-pkg": "^0.4.2", - "tinypool": "^0.2.4", - "tinyspy": "^1.0.0", - "vite": "^2.9.12 || ^3.0.0-0" + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "source-map": "^0.6.1", + "std-env": "^3.3.1", + "strip-literal": "^1.0.0", + "tinybench": "^2.3.1", + "tinypool": "^0.4.0", + "tinyspy": "^1.0.2", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.29.8", + "why-is-node-running": "^2.2.2" }, "bin": { "vitest": "vitest.mjs" @@ -1420,9 +1807,11 @@ "@edge-runtime/vm": "*", "@vitest/browser": "*", "@vitest/ui": "*", - "c8": "*", "happy-dom": "*", - "jsdom": "*" + "jsdom": "*", + "playwright": "*", + "safaridriver": "*", + "webdriverio": "*" }, "peerDependenciesMeta": { "@edge-runtime/vm": { @@ -1434,14 +1823,20 @@ "@vitest/ui": { "optional": true }, - "c8": { - "optional": true - }, "happy-dom": { "optional": true }, "jsdom": { "optional": true + }, + "playwright": { + "optional": true + }, + "safaridriver": { + "optional": true + }, + "webdriverio": { + "optional": true } } }, @@ -1501,6 +1896,34 @@ "node": ">= 8" } }, + "node_modules/why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dev": true, + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/zod": { "version": "3.17.10", "license": "MIT", @@ -1520,9 +1943,9 @@ } }, "@types/chai": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", - "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz", + "integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==", "dev": true }, "@types/chai-subset": { @@ -1586,6 +2009,49 @@ "@types/node": "*" } }, + "@vitest/expect": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.29.8.tgz", + "integrity": "sha512-xlcVXn5I5oTq6NiZSY3ykyWixBxr5mG8HYtjvpgg6KaqHm0mvhX18xuwl5YGxIRNt/A5jidd7CWcNHrSvgaQqQ==", + "dev": true, + "requires": { + "@vitest/spy": "0.29.8", + "@vitest/utils": "0.29.8", + "chai": "^4.3.7" + } + }, + "@vitest/runner": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-0.29.8.tgz", + "integrity": "sha512-FzdhnRDwEr/A3Oo1jtIk/B952BBvP32n1ObMEb23oEJNO+qO5cBet6M2XWIDQmA7BDKGKvmhUf2naXyp/2JEwQ==", + "dev": true, + "requires": { + "@vitest/utils": "0.29.8", + "p-limit": "^4.0.0", + "pathe": "^1.1.0" + } + }, + "@vitest/spy": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-0.29.8.tgz", + "integrity": "sha512-VdjBe9w34vOMl5I5mYEzNX8inTxrZ+tYUVk9jxaZJmHFwmDFC/GV3KBFTA/JKswr3XHvZL+FE/yq5EVhb6pSAw==", + "dev": true, + "requires": { + "tinyspy": "^1.0.2" + } + }, + "@vitest/utils": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-0.29.8.tgz", + "integrity": "sha512-qGzuf3vrTbnoY+RjjVVIBYfuWMjn3UMUqyQtdGNZ6ZIIyte7B37exj6LaVkrZiUTvzSadVvO/tJm8AEgbGCBPg==", + "dev": true, + "requires": { + "cli-truncate": "^3.1.0", + "diff": "^5.1.0", + "loupe": "^2.3.6", + "pretty-format": "^27.5.1" + } + }, "accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -1595,6 +2061,30 @@ "negotiator": "0.6.3" } }, + "acorn": { + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true + }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true + }, "anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -1655,6 +2145,12 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, + "cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true + }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -1665,14 +2161,14 @@ } }, "chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", "dev": true, "requires": { "assertion-error": "^1.1.0", "check-error": "^1.0.2", - "deep-eql": "^3.0.1", + "deep-eql": "^4.1.2", "get-func-name": "^2.0.0", "loupe": "^2.3.1", "pathval": "^1.1.1", @@ -1701,6 +2197,16 @@ "readdirp": "~3.6.0" } }, + "cli-truncate": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz", + "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==", + "dev": true, + "requires": { + "slice-ansi": "^5.0.0", + "string-width": "^5.0.0" + } + }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1762,9 +2268,9 @@ } }, "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "dev": true, "requires": { "type-detect": "^4.0.0" @@ -1780,11 +2286,29 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, + "diff": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", + "dev": true + }, + "eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, + "emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -2005,6 +2529,12 @@ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, + "is-fullwidth-code-point": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", + "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", + "dev": true + }, "is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2026,6 +2556,12 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, + "jsonc-parser": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", + "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", + "dev": true + }, "local-pkg": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-0.4.2.tgz", @@ -2033,9 +2569,9 @@ "dev": true }, "loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", "dev": true, "requires": { "get-func-name": "^2.0.0" @@ -2074,6 +2610,18 @@ "mime-db": "1.52.0" } }, + "mlly": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.2.0.tgz", + "integrity": "sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==", + "dev": true, + "requires": { + "acorn": "^8.8.2", + "pathe": "^1.1.0", + "pkg-types": "^1.0.2", + "ufo": "^1.1.1" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -2118,6 +2666,15 @@ "ee-first": "1.1.1" } }, + "p-limit": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", + "dev": true, + "requires": { + "yocto-queue": "^1.0.0" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -2140,6 +2697,12 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "pathe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.0.tgz", + "integrity": "sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==", + "dev": true + }, "pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -2158,6 +2721,17 @@ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, + "pkg-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.0.2.tgz", + "integrity": "sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==", + "dev": true, + "requires": { + "jsonc-parser": "^3.2.0", + "mlly": "^1.1.1", + "pathe": "^1.1.0" + } + }, "postcss": { "version": "8.4.16", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", @@ -2169,6 +2743,17 @@ "source-map-js": "^1.0.2" } }, + "pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + } + }, "proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -2202,6 +2787,12 @@ "unpipe": "1.0.0" } }, + "react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true + }, "readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -2305,31 +2896,118 @@ "object-inspect": "^1.9.0" } }, + "siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true + }, + "slice-ansi": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", + "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", + "dev": true, + "requires": { + "ansi-styles": "^6.0.0", + "is-fullwidth-code-point": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true + } + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, "source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "dev": true }, + "stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true + }, "statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" }, + "std-env": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.3.2.tgz", + "integrity": "sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==", + "dev": true + }, + "string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "requires": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + } + }, + "strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "dev": true, + "requires": { + "ansi-regex": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true + } + } + }, + "strip-literal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.0.1.tgz", + "integrity": "sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==", + "dev": true, + "requires": { + "acorn": "^8.8.2" + } + }, "supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tinybench": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.4.0.tgz", + "integrity": "sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==", + "dev": true + }, "tinypool": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.2.4.tgz", - "integrity": "sha512-Vs3rhkUH6Qq1t5bqtb816oT+HeJTXfwt2cbPH17sWHIYKTotQIFPk3tf2fgqRrVyMDVOc1EnPgzIxfIulXVzwQ==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.4.0.tgz", + "integrity": "sha512-2ksntHOKf893wSAH4z/+JbPpi92esw8Gn9N2deXX+B0EO92hexAVI9GIZZPx7P5aYo5KULfeOSt3kMOmSOy6uA==", "dev": true }, "tinyspy": { - "version": "1.0.0", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-1.1.1.tgz", + "integrity": "sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==", "dev": true }, "to-regex-range": { @@ -2373,6 +3051,12 @@ "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true }, + "ufo": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.1.1.tgz", + "integrity": "sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==", + "dev": true + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -2399,21 +3083,67 @@ "rollup": "^2.75.6" } }, + "vite-node": { + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.8.tgz", + "integrity": "sha512-b6OtCXfk65L6SElVM20q5G546yu10/kNrhg08afEoWlFRJXFq9/6glsvSVY+aI6YeC1tu2TtAqI2jHEQmOmsFw==", + "dev": true, + "requires": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "mlly": "^1.1.0", + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "vite": "^3.0.0 || ^4.0.0" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } + } + }, "vitest": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.21.1.tgz", - "integrity": "sha512-WBIxuFmIDPuK47GO6Lu9eNeRMqHj/FWL3dk73OHH3eyPPWPiu+UB3QHLkLK2PEggCqJW4FaWoWg8R68S7p9+9Q==", + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.29.8.tgz", + "integrity": "sha512-JIAVi2GK5cvA6awGpH0HvH/gEG9PZ0a/WoxdiV3PmqK+3CjQMf8c+J/Vhv4mdZ2nRyXFw66sAg6qz7VNkaHfDQ==", "dev": true, "requires": { - "@types/chai": "^4.3.3", + "@types/chai": "^4.3.4", "@types/chai-subset": "^1.3.3", "@types/node": "*", - "chai": "^4.3.6", + "@vitest/expect": "0.29.8", + "@vitest/runner": "0.29.8", + "@vitest/spy": "0.29.8", + "@vitest/utils": "0.29.8", + "acorn": "^8.8.1", + "acorn-walk": "^8.2.0", + "cac": "^6.7.14", + "chai": "^4.3.7", "debug": "^4.3.4", "local-pkg": "^0.4.2", - "tinypool": "^0.2.4", - "tinyspy": "^1.0.0", - "vite": "^2.9.12 || ^3.0.0-0" + "pathe": "^1.1.0", + "picocolors": "^1.0.0", + "source-map": "^0.6.1", + "std-env": "^3.3.1", + "strip-literal": "^1.0.0", + "tinybench": "^2.3.1", + "tinypool": "^0.4.0", + "tinyspy": "^1.0.2", + "vite": "^3.0.0 || ^4.0.0", + "vite-node": "0.29.8", + "why-is-node-running": "^2.2.2" }, "dependencies": { "debug": { @@ -2456,6 +3186,22 @@ "isexe": "^2.0.0" } }, + "why-is-node-running": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", + "integrity": "sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==", + "dev": true, + "requires": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + } + }, + "yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true + }, "zod": { "version": "3.17.10" } diff --git a/package.json b/package.json index 6667aecb..168853ae 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,14 @@ "cross-env": "^7.0.3", "cross-fetch": "^3.1.5", "typescript": "^4.8.3", - "vitest": "^0.21.1" + "vitest": "^0.29.8" }, "scripts": { "exercise": "node scripts/exercise.js", "e": "npm run exercise", "solution": "cross-env SOLUTION=true node scripts/exercise.js", "s": "npm run solution", + "ci": "(cd scripts/tests && npx vitest run)", "prepare": "node scripts/prepare-stackblitz.js", "e-01": "npm run exercise -- 01", "s-01": "npm run solution -- 01", diff --git a/scripts/tests/__snapshots__/all.test.ts.snap b/scripts/tests/__snapshots__/all.test.ts.snap new file mode 100644 index 00000000..4f2855da --- /dev/null +++ b/scripts/tests/__snapshots__/all.test.ts.snap @@ -0,0 +1,762 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`tsc > Should have the correct TypeScript errors 1`] = ` +",src/01-number.problem.ts(3,31): error TS7006: Parameter 'a' implicitly has an 'any' type. +src/01-number.problem.ts(3,34): error TS7006: Parameter 'b' implicitly has an 'any' type. +src/02-object-param.problem.ts(3,31): error TS7006: Parameter 'params' implicitly has an 'any' type. +src/03-optional-properties.problem.ts(11,24): error TS2345: Argument of type '{ first: string; }' is not assignable to parameter of type '{ first: string; last: string; }'. + Property 'last' is missing in type '{ first: string; }' but required in type '{ first: string; last: string; }'. +src/04-optional-params.problem.ts(11,16): error TS2554: Expected 2 arguments, but got 1. +src/05-assigning-types-to-variables.problem.ts(21,20): error TS2345: Argument of type '{}' is not assignable to parameter of type 'User'. + Type '{}' is missing the following properties from type 'User': id, firstName, lastName, isAdmin +src/06-unions.problem.ts(18,3): error TS2578: Unused '@ts-expect-error' directive. +src/07-arrays.problem.ts(19,3): error TS2739: Type '{ id: number; title: string; }[]' is missing the following properties from type 'Post': id, title +src/08-function-return-type-annotations.problem.ts(27,15): error TS2339: Property 'id' does not exist on type '{}'. +src/08-function-return-type-annotations.problem.ts(28,15): error TS2339: Property 'firstName' does not exist on type '{}'. +src/08-function-return-type-annotations.problem.ts(29,15): error TS2339: Property 'lastName' does not exist on type '{}'. +src/08-function-return-type-annotations.problem.ts(30,15): error TS2339: Property 'role' does not exist on type '{}'. +src/08-function-return-type-annotations.problem.ts(32,15): error TS2339: Property 'posts' does not exist on type '{}'. +src/08-function-return-type-annotations.problem.ts(33,15): error TS2339: Property 'posts' does not exist on type '{}'. +src/09-promises.problem.ts(12,45): error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? +src/10-set.problem.ts(15,3): error TS2578: Unused '@ts-expect-error' directive. +src/10-set.problem.ts(22,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. +src/11-record.problem.ts(7,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. + No index signature with a parameter of type 'string' was found on type '{}'. +src/11-record.problem.ts(11,12): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. + No index signature with a parameter of type 'string' was found on type '{}'. +src/11-record.problem.ts(26,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. + Property '123' does not exist on type '{}'. +src/11-record.problem.ts(35,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. + Property '123' does not exist on type '{}'. +src/13-catch-blocks.problem.ts(9,12): error TS2571: Object is of type 'unknown'. +src/15-intersection.problem.ts(34,13): error TS2571: Object is of type 'unknown'. +src/16-omit-and-pick.problem.ts(16,22): error TS2344: Type 'false' does not satisfy the constraint 'true'. +src/17-function-types.problem.ts(8,5): error TS2571: Object is of type 'unknown'. +src/17-function-types.problem.ts(12,5): error TS2571: Object is of type 'unknown'. +src/17-function-types.problem.ts(16,14): error TS7006: Parameter 'isFocused' implicitly has an 'any' type. +src/17-function-types.problem.ts(19,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. +src/18-function-types-with-promises.problem.ts(13,32): error TS2571: Object is of type 'unknown'. +src/18-function-types-with-promises.problem.ts(15,22): error TS2571: Object is of type 'unknown'. +src/18-function-types-with-promises.problem.ts(23,12): error TS7006: Parameter 'id' implicitly has an 'any' type. +," +`; + +exports[`vitest > Should have the correct Vitest errors 1`] = ` +{ + "success": false, + "testResults": [ + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/01-number.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/01-number.solution.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add the two numbers together", + "status": "passed", + "title": "Should add the two numbers together", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.3.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with just the first name", + "status": "passed", + "title": "Should work with just the first name", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with the first and last name", + "status": "passed", + "title": "Should work with the first and last name", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/03-optional-properties.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with just the first name", + "status": "passed", + "title": "Should work with just the first name", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with the first and last name", + "status": "passed", + "title": "Should work with the first and last name", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/03-optional-properties.solution.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with just the first name", + "status": "passed", + "title": "Should work with just the first name", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with the first and last name", + "status": "passed", + "title": "Should work with the first and last name", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/04-optional-params.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with just the first name", + "status": "passed", + "title": "Should work with just the first name", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should work with the first and last name", + "status": "passed", + "title": "Should work with the first and last name", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/04-optional-params.solution.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [ + "expected undefined to deeply equal 1", + ], + "fullName": " Should get the user id", + "location": { + "column": 34, + "line": 21, + }, + "status": "failed", + "title": "Should get the user id", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/05-assigning-types-to-variables.problem.ts", + "status": "failed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should get the user id", + "status": "passed", + "title": "Should get the user id", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/05-assigning-types-to-variables.solution.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/06-unions.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/06-unions.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/06-unions.solution.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/06-unions.solution.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/07-arrays.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/07-arrays.solution.1.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/07-arrays.solution.2.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [ + "expected undefined to be type of 'number'", + ], + "fullName": " Should return a valid user", + "location": { + "column": 19, + "line": 27, + }, + "status": "failed", + "title": "Should return a valid user", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/08-function-return-type-annotations.problem.ts", + "status": "failed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return a valid user", + "status": "passed", + "title": "Should return a valid user", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/08-function-return-type-annotations.solution.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/09-promises.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/09-promises.solution.1.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/09-promises.solution.2.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/09-promises.solution.3.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.3.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should contain Jimi and Eric", + "status": "passed", + "title": "Should contain Jimi and Eric", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should give a type error when you try to pass a non-string", + "status": "passed", + "title": "Should give a type error when you try to pass a non-string", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should be typed as an array of strings", + "status": "passed", + "title": "Should be typed as an array of strings", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/10-set.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should contain Jimi and Eric", + "status": "passed", + "title": "Should contain Jimi and Eric", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should give a type error when you try to pass a non-string", + "status": "passed", + "title": "Should give a type error when you try to pass a non-string", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should be typed as an array of strings", + "status": "passed", + "title": "Should be typed as an array of strings", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/10-set.solution.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add values to the cache", + "status": "passed", + "title": "Should add values to the cache", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should remove values from the cache", + "status": "passed", + "title": "Should remove values from the cache", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add values to the cache", + "status": "passed", + "title": "Should add values to the cache", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should remove values from the cache", + "status": "passed", + "title": "Should remove values from the cache", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add values to the cache", + "status": "passed", + "title": "Should add values to the cache", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should remove values from the cache", + "status": "passed", + "title": "Should remove values from the cache", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should add values to the cache", + "status": "passed", + "title": "Should add values to the cache", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should remove values from the cache", + "status": "passed", + "title": "Should remove values from the cache", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.3.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [ + "expected undefined to deeply equal 20", + ], + "fullName": " Should return the amount when passed an object", + "location": { + "column": 40, + "line": 6, + }, + "status": "failed", + "title": "Should return the amount when passed an object", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [ + "expected undefined to deeply equal 20", + ], + "fullName": " Should return the amount when passed a number", + "location": { + "column": 28, + "line": 10, + }, + "status": "failed", + "title": "Should return the amount when passed a number", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/12-typeof-narrowing.problem.ts", + "status": "failed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the amount when passed an object", + "status": "passed", + "title": "Should return the amount when passed an object", + }, + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the amount when passed a number", + "status": "passed", + "title": "Should return the amount when passed a number", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/12-typeof-narrowing.solution.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the message when it fails", + "status": "passed", + "title": "Should return the message when it fails", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the message when it fails", + "status": "passed", + "title": "Should return the message when it fails", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the message when it fails", + "status": "passed", + "title": "Should return the message when it fails", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should return the message when it fails", + "status": "passed", + "title": "Should return the message when it fails", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.3.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/14-extends.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/14-extends.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/14-extends.solution.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/14-extends.solution.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/15-intersection.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/15-intersection.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/15-intersection.solution.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/15-intersection.solution.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/16-omit-and-pick.problem.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/16-omit-and-pick.solution.1.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "No test found in suite src/16-omit-and-pick.solution.2.ts", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "window is not defined", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.problem.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "window is not defined", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.solution.1.ts", + "status": "passed", + }, + { + "assertionResults": [], + "message": "window is not defined", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.solution.2.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should create the user, then get them", + "status": "passed", + "title": "Should create the user, then get them", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/18-function-types-with-promises.problem.ts", + "status": "passed", + }, + { + "assertionResults": [ + { + "ancestorTitles": [ + "", + ], + "failureMessages": [], + "fullName": " Should create the user, then get them", + "status": "passed", + "title": "Should create the user, then get them", + }, + ], + "message": "", + "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/18-function-types-with-promises.solution.ts", + "status": "passed", + }, + ], +} +`; diff --git a/scripts/tests/__snapshots__/tsc.test.ts.snap b/scripts/tests/__snapshots__/tsc.test.ts.snap deleted file mode 100644 index bdf0410f..00000000 --- a/scripts/tests/__snapshots__/tsc.test.ts.snap +++ /dev/null @@ -1,164 +0,0 @@ -// Vitest Snapshot v1 - -exports[`tsc > In file 01-number.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/01-number.problem.ts(3,31): error TS7006: Parameter 'a' implicitly has an 'any' type. -../../src/01-number.problem.ts(3,34): error TS7006: Parameter 'b' implicitly has an 'any' type. -," -`; - -exports[`tsc > In file 01-number.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 02-object-param.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/02-object-param.problem.ts(3,31): error TS7006: Parameter 'params' implicitly has an 'any' type. -," -`; - -exports[`tsc > In file 02-object-param.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 02-object-param.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 02-object-param.solution.3.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 03-optional-properties.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/03-optional-properties.problem.ts(11,24): error TS2345: Argument of type '{ first: string; }' is not assignable to parameter of type '{ first: string; last: string; }'. - Property 'last' is missing in type '{ first: string; }' but required in type '{ first: string; last: string; }'. -," -`; - -exports[`tsc > In file 03-optional-properties.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 04-optional-params.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/04-optional-params.problem.ts(11,16): error TS2554: Expected 2 arguments, but got 1. -," -`; - -exports[`tsc > In file 04-optional-params.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 05-assigning-types-to-variables.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/05-assigning-types-to-variables.problem.ts(21,20): error TS2345: Argument of type '{}' is not assignable to parameter of type 'User'. - Type '{}' is missing the following properties from type 'User': id, firstName, lastName, isAdmin -," -`; - -exports[`tsc > In file 05-assigning-types-to-variables.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 06-unions.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/06-unions.problem.ts(18,3): error TS2578: Unused '@ts-expect-error' directive. -," -`; - -exports[`tsc > In file 06-unions.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 07-arrays.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/07-arrays.problem.ts(19,3): error TS2739: Type '{ id: number; title: string; }[]' is missing the following properties from type 'Post': id, title -," -`; - -exports[`tsc > In file 07-arrays.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 07-arrays.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 08-function-return-type-annotations.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/08-function-return-type-annotations.problem.ts(27,15): error TS2339: Property 'id' does not exist on type '{}'. -../../src/08-function-return-type-annotations.problem.ts(28,15): error TS2339: Property 'firstName' does not exist on type '{}'. -../../src/08-function-return-type-annotations.problem.ts(29,15): error TS2339: Property 'lastName' does not exist on type '{}'. -../../src/08-function-return-type-annotations.problem.ts(30,15): error TS2339: Property 'role' does not exist on type '{}'. -../../src/08-function-return-type-annotations.problem.ts(32,15): error TS2339: Property 'posts' does not exist on type '{}'. -../../src/08-function-return-type-annotations.problem.ts(33,15): error TS2339: Property 'posts' does not exist on type '{}'. -," -`; - -exports[`tsc > In file 08-function-return-type-annotations.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 09-promises.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/09-promises.problem.ts(12,45): error TS1055: Type 'LukeSkywalker' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -," -`; - -exports[`tsc > In file 09-promises.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 09-promises.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 09-promises.solution.3.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 10-set.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/10-set.problem.ts(15,3): error TS2578: Unused '@ts-expect-error' directive. -../../src/10-set.problem.ts(22,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. -," -`; - -exports[`tsc > In file 10-set.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 11-record.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/11-record.problem.ts(7,5): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. - No index signature with a parameter of type 'string' was found on type '{}'. -../../src/11-record.problem.ts(11,12): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. - No index signature with a parameter of type 'string' was found on type '{}'. -../../src/11-record.problem.ts(26,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. - Property '123' does not exist on type '{}'. -../../src/11-record.problem.ts(35,10): error TS7053: Element implicitly has an 'any' type because expression of type '\\"123\\"' can't be used to index type '{}'. - Property '123' does not exist on type '{}'. -," -`; - -exports[`tsc > In file 11-record.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 11-record.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 11-record.solution.3.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 12-typeof-narrowing.problem.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 12-typeof-narrowing.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 13-catch-blocks.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/13-catch-blocks.problem.ts(9,12): error TS2571: Object is of type 'unknown'. -," -`; - -exports[`tsc > In file 13-catch-blocks.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 13-catch-blocks.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 13-catch-blocks.solution.3.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 14-extends.problem.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 14-extends.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 15-intersection.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/15-intersection.problem.ts(34,13): error TS2571: Object is of type 'unknown'. -," -`; - -exports[`tsc > In file 15-intersection.solution.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 16-omit-and-pick.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/16-omit-and-pick.problem.ts(16,22): error TS2344: Type 'false' does not satisfy the constraint 'true'. -," -`; - -exports[`tsc > In file 16-omit-and-pick.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 16-omit-and-pick.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 17-function-types.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/17-function-types.problem.ts(8,5): error TS2571: Object is of type 'unknown'. -../../src/17-function-types.problem.ts(12,5): error TS2571: Object is of type 'unknown'. -../../src/17-function-types.problem.ts(16,14): error TS7006: Parameter 'isFocused' implicitly has an 'any' type. -../../src/17-function-types.problem.ts(19,24): error TS2344: Type 'false' does not satisfy the constraint 'true'. -," -`; - -exports[`tsc > In file 17-function-types.solution.1.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 17-function-types.solution.2.ts, TS errors should match snapshot 1`] = `""`; - -exports[`tsc > In file 18-function-types-with-promises.problem.ts, TS errors should match snapshot 1`] = ` -",../../src/18-function-types-with-promises.problem.ts(13,32): error TS2571: Object is of type 'unknown'. -../../src/18-function-types-with-promises.problem.ts(15,22): error TS2571: Object is of type 'unknown'. -../../src/18-function-types-with-promises.problem.ts(23,12): error TS7006: Parameter 'id' implicitly has an 'any' type. -," -`; - -exports[`tsc > In file 18-function-types-with-promises.solution.ts, TS errors should match snapshot 1`] = `""`; diff --git a/scripts/tests/all.test.ts b/scripts/tests/all.test.ts new file mode 100644 index 00000000..64438410 --- /dev/null +++ b/scripts/tests/all.test.ts @@ -0,0 +1,39 @@ +import path from "path"; +import { describe, expect, it } from "vitest"; +import { execSync } from "child_process"; +import { cleanVitestOutput } from "./cleanVitestOutput"; + +const rootFolder = path.resolve(__dirname, "../.."); + +describe("tsc", async () => { + it("Should have the correct TypeScript errors", () => { + let result: string; + + try { + result = execSync(`npx tsc`, { + cwd: rootFolder, + }).toString(); + } catch (error) { + result = error.output.toString(); + } + + expect(result).toMatchSnapshot(); + }); +}); + +describe("vitest", async () => { + it("Should have the correct Vitest errors", () => { + let result: string; + + try { + result = execSync(`npx vitest run --reporter=json`, { + cwd: rootFolder, + stdio: "pipe", + }).toString(); + } catch (error) { + result = error.output.toString(); + } + + expect(cleanVitestOutput(result)).toMatchSnapshot(); + }); +}); diff --git a/scripts/tests/cleanVitestOutput.ts b/scripts/tests/cleanVitestOutput.ts new file mode 100644 index 00000000..cf0a197b --- /dev/null +++ b/scripts/tests/cleanVitestOutput.ts @@ -0,0 +1,48 @@ +export const cleanVitestOutput = (result: string) => { + const asJson: { + startTime?: number; + endTime?: number; + duration?: number; + numFailedTestSuites?: number; + numFailedTests?: number; + numPassedTestSuites?: number; + numPassedTests?: number; + numPendingTestSuites?: number; + numPendingTests?: number; + numTodoTests?: number; + numTotalTestSuites?: number; + numTotalTests?: number; + testResults: { + startTime?: number; + endTime?: number; + duration?: number; + assertionResults: { + duration?: number; + }[]; + }[]; + } = JSON.parse(result.slice(1, -1)); + + delete asJson.startTime; + delete asJson.endTime; + delete asJson.duration; + delete asJson.numFailedTestSuites; + delete asJson.numFailedTests; + delete asJson.numPassedTestSuites; + delete asJson.numPassedTests; + delete asJson.numPendingTestSuites; + delete asJson.numPendingTests; + delete asJson.numTodoTests; + delete asJson.numTotalTestSuites; + delete asJson.numTotalTests; + + asJson.testResults.forEach((testResult) => { + delete testResult.startTime; + delete testResult.endTime; + delete testResult.duration; + testResult.assertionResults.forEach((assertionResult) => { + delete assertionResult.duration; + }); + }); + + return asJson; +}; diff --git a/scripts/tests/package-lock.json b/scripts/tests/package-lock.json deleted file mode 100644 index 544795d7..00000000 --- a/scripts/tests/package-lock.json +++ /dev/null @@ -1,351 +0,0 @@ -{ - "name": "tests", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "dependencies": { - "fast-glob": "^3.2.12" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "dependencies": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - } - }, - "dependencies": { - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - } - }, - "fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", - "requires": { - "reusify": "^1.0.4" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "requires": { - "is-glob": "^4.0.1" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" - }, - "micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", - "requires": { - "braces": "^3.0.2", - "picomatch": "^2.3.1" - } - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - } - } -} diff --git a/scripts/tests/package.json b/scripts/tests/package.json deleted file mode 100644 index 7a51e6b1..00000000 --- a/scripts/tests/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "fast-glob": "^3.2.12" - } -} diff --git a/scripts/tests/tsc.test.ts b/scripts/tests/tsc.test.ts deleted file mode 100644 index c1af9542..00000000 --- a/scripts/tests/tsc.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import fg from "fast-glob"; -import path from "path"; -import { describe, expect, it } from "vitest"; -import { execSync } from "child_process"; - -const srcFolder = path.resolve(__dirname, "../../src"); - -const allFiles = path.resolve(srcFolder, "*{problem,solution,explainer}*.ts"); - -const toRelativeFilename = (file: string) => { - return path.relative(srcFolder, file); -}; - -describe("tsc", async () => { - const files = await fg(allFiles); - - it.each(files.map(toRelativeFilename))( - "In file %s, TS errors should match snapshot", - (file) => { - const resolvedFile = path.join(srcFolder, file); - let result: string; - - try { - result = execSync(`tsc "${resolvedFile}" --noEmit --strict`).toString(); - } catch (error) { - result = error.output.toString(); - } - - expect(result).toMatchSnapshot(); - }, - ); -}); diff --git a/vite.config.ts b/vite.config.ts index 7ee4b71c..7e1effe2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,8 +2,8 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { - include: ["src/**/*.ts"], - setupFiles: ["scripts/setup.ts"], + include: ["src/**/*{problem,solution}*.ts"], + setupFiles: ["./scripts/setup.ts"], passWithNoTests: true, teardownTimeout: 5000, }, From 24601e8175d287f399c29da2130f23043e699535 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 3 Apr 2023 11:06:17 +0100 Subject: [PATCH 3/3] Fixed tests --- .github/workflows/main.yml | 2 +- scripts/tests/__snapshots__/all.test.ts.snap | 94 ++++++++++---------- scripts/tests/all.test.ts | 6 +- scripts/tests/cleanVitestOutput.ts | 13 ++- 4 files changed, 65 insertions(+), 50 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c32c8ae6..77fc8f18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,7 +5,7 @@ on: - "**" jobs: - build: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/scripts/tests/__snapshots__/all.test.ts.snap b/scripts/tests/__snapshots__/all.test.ts.snap index 4f2855da..65f6a38c 100644 --- a/scripts/tests/__snapshots__/all.test.ts.snap +++ b/scripts/tests/__snapshots__/all.test.ts.snap @@ -58,7 +58,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/01-number.problem.ts", + "name": "src/01-number.problem.ts", "status": "passed", }, { @@ -74,7 +74,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/01-number.solution.ts", + "name": "src/01-number.solution.ts", "status": "passed", }, { @@ -90,7 +90,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.problem.ts", + "name": "src/02-object-param.problem.ts", "status": "passed", }, { @@ -106,7 +106,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.1.ts", + "name": "src/02-object-param.solution.1.ts", "status": "passed", }, { @@ -122,7 +122,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.2.ts", + "name": "src/02-object-param.solution.2.ts", "status": "passed", }, { @@ -138,7 +138,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/02-object-param.solution.3.ts", + "name": "src/02-object-param.solution.3.ts", "status": "passed", }, { @@ -163,7 +163,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/03-optional-properties.problem.ts", + "name": "src/03-optional-properties.problem.ts", "status": "passed", }, { @@ -188,7 +188,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/03-optional-properties.solution.ts", + "name": "src/03-optional-properties.solution.ts", "status": "passed", }, { @@ -213,7 +213,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/04-optional-params.problem.ts", + "name": "src/04-optional-params.problem.ts", "status": "passed", }, { @@ -238,7 +238,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/04-optional-params.solution.ts", + "name": "src/04-optional-params.solution.ts", "status": "passed", }, { @@ -260,7 +260,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/05-assigning-types-to-variables.problem.ts", + "name": "src/05-assigning-types-to-variables.problem.ts", "status": "failed", }, { @@ -276,37 +276,37 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/05-assigning-types-to-variables.solution.ts", + "name": "src/05-assigning-types-to-variables.solution.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/06-unions.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/06-unions.problem.ts", + "name": "src/06-unions.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/06-unions.solution.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/06-unions.solution.ts", + "name": "src/06-unions.solution.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/07-arrays.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.problem.ts", + "name": "src/07-arrays.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/07-arrays.solution.1.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.solution.1.ts", + "name": "src/07-arrays.solution.1.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/07-arrays.solution.2.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/07-arrays.solution.2.ts", + "name": "src/07-arrays.solution.2.ts", "status": "passed", }, { @@ -328,7 +328,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/08-function-return-type-annotations.problem.ts", + "name": "src/08-function-return-type-annotations.problem.ts", "status": "failed", }, { @@ -344,31 +344,31 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/08-function-return-type-annotations.solution.ts", + "name": "src/08-function-return-type-annotations.solution.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/09-promises.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.problem.ts", + "name": "src/09-promises.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/09-promises.solution.1.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.1.ts", + "name": "src/09-promises.solution.1.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/09-promises.solution.2.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.2.ts", + "name": "src/09-promises.solution.2.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/09-promises.solution.3.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/09-promises.solution.3.ts", + "name": "src/09-promises.solution.3.ts", "status": "passed", }, { @@ -402,7 +402,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/10-set.problem.ts", + "name": "src/10-set.problem.ts", "status": "passed", }, { @@ -436,7 +436,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/10-set.solution.ts", + "name": "src/10-set.solution.ts", "status": "passed", }, { @@ -461,7 +461,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.problem.ts", + "name": "src/11-record.problem.ts", "status": "passed", }, { @@ -486,7 +486,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.1.ts", + "name": "src/11-record.solution.1.ts", "status": "passed", }, { @@ -511,7 +511,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.2.ts", + "name": "src/11-record.solution.2.ts", "status": "passed", }, { @@ -536,7 +536,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/11-record.solution.3.ts", + "name": "src/11-record.solution.3.ts", "status": "passed", }, { @@ -573,7 +573,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/12-typeof-narrowing.problem.ts", + "name": "src/12-typeof-narrowing.problem.ts", "status": "failed", }, { @@ -598,7 +598,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/12-typeof-narrowing.solution.ts", + "name": "src/12-typeof-narrowing.solution.ts", "status": "passed", }, { @@ -614,7 +614,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.problem.ts", + "name": "src/13-catch-blocks.problem.ts", "status": "passed", }, { @@ -630,7 +630,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.1.ts", + "name": "src/13-catch-blocks.solution.1.ts", "status": "passed", }, { @@ -646,7 +646,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.2.ts", + "name": "src/13-catch-blocks.solution.2.ts", "status": "passed", }, { @@ -662,67 +662,67 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/13-catch-blocks.solution.3.ts", + "name": "src/13-catch-blocks.solution.3.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/14-extends.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/14-extends.problem.ts", + "name": "src/14-extends.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/14-extends.solution.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/14-extends.solution.ts", + "name": "src/14-extends.solution.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/15-intersection.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/15-intersection.problem.ts", + "name": "src/15-intersection.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/15-intersection.solution.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/15-intersection.solution.ts", + "name": "src/15-intersection.solution.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/16-omit-and-pick.problem.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.problem.ts", + "name": "src/16-omit-and-pick.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/16-omit-and-pick.solution.1.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.solution.1.ts", + "name": "src/16-omit-and-pick.solution.1.ts", "status": "passed", }, { "assertionResults": [], "message": "No test found in suite src/16-omit-and-pick.solution.2.ts", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/16-omit-and-pick.solution.2.ts", + "name": "src/16-omit-and-pick.solution.2.ts", "status": "passed", }, { "assertionResults": [], "message": "window is not defined", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.problem.ts", + "name": "src/17-function-types.problem.ts", "status": "passed", }, { "assertionResults": [], "message": "window is not defined", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.solution.1.ts", + "name": "src/17-function-types.solution.1.ts", "status": "passed", }, { "assertionResults": [], "message": "window is not defined", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/17-function-types.solution.2.ts", + "name": "src/17-function-types.solution.2.ts", "status": "passed", }, { @@ -738,7 +738,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/18-function-types-with-promises.problem.ts", + "name": "src/18-function-types-with-promises.problem.ts", "status": "passed", }, { @@ -754,7 +754,7 @@ exports[`vitest > Should have the correct Vitest errors 1`] = ` }, ], "message": "", - "name": "/Users/matt/repos/ts/beginners-typescript-tutorial/src/18-function-types-with-promises.solution.ts", + "name": "src/18-function-types-with-promises.solution.ts", "status": "passed", }, ], diff --git a/scripts/tests/all.test.ts b/scripts/tests/all.test.ts index 64438410..a7867dee 100644 --- a/scripts/tests/all.test.ts +++ b/scripts/tests/all.test.ts @@ -34,6 +34,10 @@ describe("vitest", async () => { result = error.output.toString(); } - expect(cleanVitestOutput(result)).toMatchSnapshot(); + expect( + cleanVitestOutput(result, { + rootFolder, + }), + ).toMatchSnapshot(); }); }); diff --git a/scripts/tests/cleanVitestOutput.ts b/scripts/tests/cleanVitestOutput.ts index cf0a197b..54b4e029 100644 --- a/scripts/tests/cleanVitestOutput.ts +++ b/scripts/tests/cleanVitestOutput.ts @@ -1,4 +1,11 @@ -export const cleanVitestOutput = (result: string) => { +import path from "path"; + +export const cleanVitestOutput = ( + result: string, + context: { + rootFolder: string; + }, +) => { const asJson: { startTime?: number; endTime?: number; @@ -13,6 +20,7 @@ export const cleanVitestOutput = (result: string) => { numTotalTestSuites?: number; numTotalTests?: number; testResults: { + name: string; startTime?: number; endTime?: number; duration?: number; @@ -39,6 +47,9 @@ export const cleanVitestOutput = (result: string) => { delete testResult.startTime; delete testResult.endTime; delete testResult.duration; + + testResult.name = path.relative(context.rootFolder, testResult.name); + testResult.assertionResults.forEach((assertionResult) => { delete assertionResult.duration; }); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy