Skip to content

Commit

Permalink
Merge pull request #454 from bcgov/feature/test-design-tokens-build
Browse files Browse the repository at this point in the history
Test design tokens build
  • Loading branch information
ty2k authored Aug 19, 2024
2 parents bb061f8 + 196e15d commit f830789
Show file tree
Hide file tree
Showing 4 changed files with 475 additions and 161 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/test_design_tokens_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test design tokens build script

on:
pull_request:
paths:
- packages/design-tokens/**
workflow_dispatch:

# Cancel any currently running builds to save GitHub Actions hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read .nvmrc
run: echo "GITHUB_NVMRC_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
working-directory: ./packages/design-tokens

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GITHUB_NVMRC_VERSION }}

- name: Install dependencies
run: npm install
working-directory: ./packages/design-tokens

- name: Run test suite with npm script
run: npm run test
working-directory: ./packages/design-tokens
23 changes: 23 additions & 0 deletions packages/design-tokens/build-output.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { exec } from "child_process";
import { test } from "node:test";
import assert from "node:assert";

test("build-output.js should complete without errors", async () => {
try {
await new Promise((resolve, reject) => {
// Execute the build script using Node.js
exec("node build-output.js", (error, stdout, stderr) => {
// If there was an error, the test should fail
if (error) {
console.error("Error executing build-output.js:", stderr);
return reject(new Error("build-output.js threw an error"));
}
console.log("build-output.js executed successfully:", stdout);
resolve();
});
});
assert.ok(true);
} catch (error) {
assert.fail(error.message);
}
});
Loading

0 comments on commit f830789

Please sign in to comment.