From 62f30a389e3231788cb2140cd5d3a7ecdcc04d23 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Wed, 31 Jul 2024 23:04:43 +0200 Subject: [PATCH] Add run instructions (tests) --- README.md | 220 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f49ceb5..6d4bc1b 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,225 @@ corepack yarn dlx @yarnpkg/sdks vscode Running the tests of the test-runner itself can be achieved by using the `test` script from `package.json`. The tests delegate to the _build output_, which is why `corepack yarn test` first calls `corepack yarn build` before running `corepack yarn test:bare`. -**The tests take over a minute to run on a decent machine**. + +You can run individual test sets: + +```shell +$ corepack yarn node test/skip.test.mjs + +skipping via test.skip > passing solution +assert pass +``` + +Or turn on output by setting `SILENT=0`. On Windows (requires Git Bash or similar) that would become: + +```shell +$ corepack yarn dlx cross-env SILENT=0 corepack yarn node test/skip.test.mjs + +➤ YN0000: · Yarn 4.3.1 +➤ YN0000: ┌ Resolution step +➤ YN0085: │ + cross-env@npm:7.0.3, cross-spawn@npm:7.0.3, isexe@npm:2.0.0, path-key@npm:3.1.1, shebang-command@npm:2.0.0, shebang-regex@npm:3.0.0, which@npm:2.0.2 +➤ YN0000: └ Completed +➤ YN0000: ┌ Fetch step +➤ YN0000: └ Completed +➤ YN0000: ┌ Link step +➤ YN0000: └ Completed +➤ YN0000: · Done in 0s 232ms + +skipping via test.skip > passing solution + +╔═════════════════════════════════════════════════════════════╗ + 🔧 Process input arguments for run +╚═════════════════════════════════════════════════════════════╝ + +✔️ Using reporter : C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner/dist/reporter.js +✔️ Using test-root: C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner/test/fixtures/pythagorean-triplet/chroth7/ +✔️ Using base-root: C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner +✔️ Using setup-env: C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner/dist/jest/setup.js + +╔═════════════════════════════════════════════════════════════╗ + 🔧 Preparing run +╚═════════════════════════════════════════════════════════════╝ + +Input does not match output directory. +👁️ C:/Users/Derk-Jan/AppData/Local/Temp/foo-xbaeYM/ +✔️ Copying C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner/test/fixtures/pythagorean-triplet/chroth7/ to output. + +If the solution contains babel.config.js, package.json, +or tsconfig.json at the root, these configuration files will +be used during the test-runner process which we do not want. +The test-runner will therefore temporarily rename these files. + +✔️ renaming babel.config.js in output so it can be replaced. +✔️ renaming package.json in output so it can be replaced. +✔️ renaming tsconfig.json in output so it can be replaced. + +The output directory is likely not placed inside the test +runner root. This means the CLI tools need configuration +files as given and understood by the test-runner for running +the tests. Will now turn the output directory into a +standalone package. + +✔️ .yarn cache from root to output +✔️ .yarnrc.yml from root to output +✔️ .yarn.lock from root to output +✔️ .pnp.cjs from root to output +✔️ .pnp.loader.mjs from root to output +✔️ babel.config.js from root to output +✔️ package.json from root to output +✔️ tsconfig.json from root to output + +The results of this run will be written to 'results.json'. +👁️ C:/Users/Derk-Jan/AppData/Local/Temp/foo-xbaeYM/results.json + +╔═════════════════════════════════════════════════════════════╗ + 🔧 Preparing test suite file(s) +╚═════════════════════════════════════════════════════════════╝ + +There is a configuration file in the expected .meta location +which will now be used to determine which test files to prep. +👁️ C:/Users/Derk-Jan/Documents/GitHub/exercism/typescript-test-runner/test/fixtures/pythagorean-triplet/chroth7/.meta/config.json +{ + "blurb": "There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product a * b * c.", + "authors": ["mdowds"], + "contributors": ["masters3d", "mdmower", "SleeplessByte"], + "files": { + "solution": ["pythagorean-triplet.ts"], + "test": ["pythagorean-triplet.test.ts"], + "example": [".meta/proof.ci.ts"] + }, + "source": "Problem 9 at Project Euler", + "source_url": "http://projecteuler.net/problem=9" +} + +Enabling tests in C:/Users/Derk-Jan/AppData/Local/Temp/foo-xbaeYM/pythagorean-triplet.test.ts + +╔═════════════════════════════════════════════════════════════╗ + 🔧 Preparing test project +╚═════════════════════════════════════════════════════════════╝ + +✔️ enabling corepack +✔️ yarn version now: 4.3.1 + +✔️ standalone package found installing packages from cache + +total 3779 +drwxr-xr-x 1 197612 197612 0 Jul 31 23:03 . +drwxr-xr-x 1 197612 197612 0 Jul 31 23:03 .. +drwxr-xr-x 1 197612 197612 0 Jul 31 23:03 .docs +-rw-r--r-- 1 197612 197612 132 Jul 31 23:03 .eslintignore +-rw-r--r-- 1 197612 197612 518 Jul 31 23:03 .eslintrc +drwxr-xr-x 1 197612 197612 0 Jul 31 23:03 .meta +-rwxr-xr-x 1 197612 197612 884757 Jul 31 23:03 .pnp.cjs +-rw-r--r-- 1 197612 197612 73628 Jul 31 23:03 .pnp.loader.mjs +drwxr-xr-x 1 197612 197612 0 Jul 31 23:03 .yarn +-rw-r--r-- 1 197612 197612 235 Jul 31 23:03 .yarnrc.yml +-rw-r--r-- 1 197612 197612 257 Jul 31 23:03 babel.config.js +-rw-r--r-- 1 197612 197612 374 Jul 31 23:03 babel.config.js.💥.bak +-rw-r--r-- 1 197612 197612 2332 Jul 31 23:03 expected_results.json +-rw-r--r-- 1 197612 197612 407 Jul 31 23:03 jest.config.js +-rw-r--r-- 1 197612 197612 2182 Jul 31 23:03 package.json +-rw-r--r-- 1 197612 197612 992 Jul 31 23:03 package.json.💥.bak +-rw-r--r-- 1 197612 197612 1902 Jul 31 23:03 pythagorean-triplet.test.ts +-rw-r--r-- 1 197612 197612 1461 Jul 31 23:03 pythagorean-triplet.ts +-rw-r--r-- 1 197612 197612 2332 Jul 31 23:03 results.json +-rw-r--r-- 1 197612 197612 1262 Jul 31 23:03 tsconfig.json +-rw-r--r-- 1 197612 197612 487 Jul 31 23:03 tsconfig.json.💥.bak +-rw-r--r-- 1 197612 197612 249470 Jul 31 23:03 yarn.lock + +➤ YN0000: · Yarn 4.3.1 +➤ YN0000: ┌ Project validation +➤ YN0090: │ Offline work is enabled; Yarn won't fetch packages from the remote registry if it can avoid it +➤ YN0000: └ Completed +➤ YN0000: ┌ Resolution step +➤ YN0000: └ Completed in 0s 502ms +➤ YN0000: ┌ Post-resolution validation +➤ YN0060: │ eslint is listed by your project with version 9.8.0 (pc52f3), which doesn't satisfy what @exercism/eslint-config-tooling and other dependencies request (but they have non-overlapping ranges!). +➤ YN0002: │ @exercism/typescript-test-runner@workspace:. doesn't provide @babel/core (p9b671), requested by babel-jest. +➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements for details, where is the six-letter p-prefixed code. +➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details. +➤ YN0000: └ Completed +➤ YN0000: ┌ Fetch step +➤ YN0000: └ Completed +➤ YN0000: ┌ Link step +➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental +➤ YN0008: │ core-js@npm:3.37.1 must be rebuilt because its dependency tree changed +➤ YN0000: └ Completed in 0s 239ms +➤ YN0000: · Done with warnings in 0s 952ms + +╔═════════════════════════════════════════════════════════════╗ + ➤ Step 1/3: Build (tests: does it compile?) +╚═════════════════════════════════════════════════════════════╝ + +✔️ found a tsconfig.json (as expected) +👁️ C:/Users/Derk-Jan/AppData/Local/Temp/foo-xbaeYM/tsconfig.json +{ + "extends": "@tsconfig/node20/tsconfig.json", + "compilerOptions": { + // Allows you to use the newest syntax, and have access to console.log + // https://www.typescriptlang.org/tsconfig#lib + "lib": ["ES2020", "dom"], + // Make sure typescript is configured to output ESM + // https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-make-my-typescript-project-output-esm + "module": "Node16", + // Since this project is using babel, TypeScript may target something very + // high, and babel will make sure it runs on your local Node version. + // https://babeljs.io/docs/en/ + "target": "ES2020", // ESLint doesn't support this yet: "es2022", + + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + + // Because jest-resolve isn't like node resolve, the absolute path must be .ts + "allowImportingTsExtensions": true, + "noEmit": true, + + // Because we'll be using babel: ensure that Babel can safely transpile + // files in the TypeScript project. + // + // https://babeljs.io/docs/en/babel-plugin-transform-typescript/#caveats + "isolatedModules": true + }, + "exclude": [".meta/*", "__typetests__/*", "*.test.ts", "*.tst.ts"] +} + +⚙️ corepack yarn run tsc + + +✅ tsc compilation success + +╔═════════════════════════════════════════════════════════════╗ + ➤ Step 2/3: Type tests (tests: are the types as expected?) +╚═════════════════════════════════════════════════════════════╝ + +✅ no type tests (*.tst.ts) discovered. + +╔═════════════════════════════════════════════════════════════╗ + ➤ Step 3/3: Execution (tests: does the solution work?) +╚═════════════════════════════════════════════════════════════╝ + +✔️ jest tests (*.test.ts) discovered. +C:\Users\Derk-Jan\AppData\Local\Temp\foo-xbaeYM\pythagorean-triplet.test.ts + +⚙️ corepack yarn jest <...> + +✅ all tests (*.test.ts) passed. + +If the solution previously contained configuration files, +they were disabled and now need to be restored. + +✔️ restoring babel.config.js in output +✔️ restoring package.json in output +✔️ restoring tsconfig.json in output + +--------------------------------------------------------------- +The results of this run have been written to 'results.json'. +👁️ C:/Users/Derk-Jan/AppData/Local/Temp/foo-xbaeYM/results.json + +assert pass +``` [web-exercism]: https://exercism.io [git-automated-tests]: https://github.com/exercism/automated-tests