-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #454 from bcgov/feature/test-design-tokens-build
Test design tokens build
- Loading branch information
Showing
4 changed files
with
475 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}); |
Oops, something went wrong.