CAITSGet started

Commands

The scripts of a CAITS project, the commands of CAITS, the environment variables, and the reports. init writes the scripts in package.json: they are yours to change.

The scripts of every day

ScriptWhat it does
npm run devStarts the app on http://localhost:3000, and reloads it as you edit.
npm run tddRuns the unit tests, then, at each save, the tests of the files you changed. In an AI agent, it runs them once and stops: run it again after a change.
npm testRuns every unit test, contracts and integration tests included.
npm run checkRuns every check at once, prints the output of the failing ones only, and writes the reports. Run it before each commit.
npm run buildBuilds the app for production, in dist/.
npm startStarts the production build on port PORT.

The scripts of each check

npm run check runs six of these at once, each in its own build folder. To fix one check, run its script alone. The harness shows what each one catches.

ScriptWhat it does
npm run typecheckBuilds the app, then checks the types of the TypeScript files and the Marko templates.
npm run lintRuns lint:code, then lint:architecture.
npm run lint:codeRuns ESLint.
npm run lint:architectureChecks the architecture rules, in under a second.
npm run test:coverageRuns the unit tests with their coverage, which must reach 100%, and writes the report of the tests.
npm run test:mutationRuns Stryker: every mutant must be killed. Then gives each file's score, and the survivors.
npm run test:e2eBuilds the app, starts it, and runs the end-to-end tests in a browser.
npm run test:unitThe unit tests, without the infra and integration tests: the fastest ones.
npm run test:contractsThe infra tests: each adapter runs the contract of its port.
npm run test:integrationThe backend, with its real adapters.

The commands of CAITS

The scripts run these commands. Run them yourself with npx caits <command>.

CommandWhat it does
caits init [folder]Makes a project, or adds CAITS to the current one: see Add CAITS to a project.
caits updateWrites the defaults of the installed CAITS to quality/caits/. Run it after you install another version. It gives the commands that add the packages and the values that package.json lacks.
caits devStarts the development server. It builds in node_modules/.caits/dev/, so npm run check can run at the same time, and restarts when the setup changes.
caits check <script>…Runs the scripts it gets, all at once. npm run check gives it the six checks: remove one, or add your own.
caits architectureChecks the rules of quality/architecture.mjs on src/ and test/.
caits e2eStarts the server of quality/playwright.config.ts, then runs the end-to-end tests.
caits mutationRuns Stryker, then runs again, with more time and fewer at once, the mutants that the clock stopped: their second result counts. Then it gives each file's score and the survivors. It fails when a mutant isn't judged. Its options go to Stryker.
caits mutation-summaryGives each file's score from the last report. With --survivors, it lists the mutants that survived, and those not judged.
caits --version, caits --helpThe installed version, and the usage of each command.

The options of init:

OptionWhat it does
--exampleWrites the example app, fetched with git from IngeniozIT/caits-example at the tag of your CAITS version.
--no-installWrites the files, but installs nothing. Then run npm install and npx playwright install chromium.
--example-source <source>To work on CAITS itself: writes the example from a git repository with # and a tag or a branch, or a folder.
--caits <source>To work on CAITS itself: where npm gets CAITS, such as file:/path/to/ingenioz-it-caits-0.8.1.tgz.

The environment variables

VariableRead byWhat it sets
PORTnpm run dev, npm startThe port of the app. Default: 3000.
HMR_PORTnpm run devThe port that sends your changes to the browser. Default: 24678. Give each project its own to run two at once.
DATA_DIRThe example appThe folder where the backend keeps its files. Default: tmp/. The end-to-end tests give each project its own, and empty it first.

The end-to-end tests start the app on port 4310. When another program uses it, caits e2e stops and says so.

The reports

npm run check writes its reports in reports/:

ReportWhat it shows
reports/test-docs/index.htmlYour tests, as a spec: what the app does, test by test. See the harness.
reports/coverage/index.htmlThe coverage, line by line.
reports/mutation/index.htmlThe mutants, file by file.