Skip to content

Jest Example

This runs jest tests on Node.js 14, 16, and 18.

typescript
import { Job, Pipeline } from "https://deno.land/x/katoa/mod.ts";

// Build a job for each Node.js version
const jobs: Job[] = ["14", "16", "18"].map(
  (nodeVersion) =>
    new Job({
      name: `Test on Node.js ${nodeVersion}`,
      image: `node:${nodeVersion}`,
      cacheDirectories: ["node_modules"],
      steps: [
        // Run shell commands to install dependencies and run tests
        {
          name: "Install dependencies",
          run: "npm install",
        },
        {
          name: "Run tests",
          run: "npx jest",
        },
      ],
    })
);

export default new Pipeline(jobs);
import { Job, Pipeline } from "https://deno.land/x/katoa/mod.ts";

// Build a job for each Node.js version
const jobs: Job[] = ["14", "16", "18"].map(
  (nodeVersion) =>
    new Job({
      name: `Test on Node.js ${nodeVersion}`,
      image: `node:${nodeVersion}`,
      cacheDirectories: ["node_modules"],
      steps: [
        // Run shell commands to install dependencies and run tests
        {
          name: "Install dependencies",
          run: "npm install",
        },
        {
          name: "Run tests",
          run: "npx jest",
        },
      ],
    })
);

export default new Pipeline(jobs);