Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(testing): add E2E tests to CI #397

Merged
merged 8 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [main]
pull_request:
branches: [main]
workflow_call:

permissions:
contents: read
Expand All @@ -30,10 +31,21 @@ jobs:
node-version: [18, 20, latest]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm test

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test

- name: Test E2E
run: npm run test:e2e
13 changes: 4 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ permissions:
contents: read # for checkout

jobs:
test:
uses: "./.github/workflows/node.js.yml"

cmwylie19 marked this conversation as resolved.
Show resolved Hide resolved
release:
name: Release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
Expand All @@ -27,15 +31,6 @@ jobs:
with:
node-version: "lts/*"

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm test

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
18 changes: 11 additions & 7 deletions e2e/cli.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ describe("End-to-End CLI tests with multiple test files", () => {
const expectedDir = path.join(__dirname, `crds/${name}.default.expected`); // Expected default directory
const expectedPostDir = path.join(__dirname, `crds/${name}.no.post.expected`); // Expected post-processing directory

console.log(`Running tests for ${name}`);
console.log(`Test file: ${mockYamlPath}`);
console.log(`Output directory: ${mockDir}`);
console.log(`Expected directory: ${expectedDir}`);
console.log(`Expected post-processing directory: ${expectedPostDir}`);
const testInfoMessage = `
Running tests for ${name}
Test file: ${mockYamlPath}
Output directory: ${mockDir}
Expected directory: ${expectedDir}
Expected post-processing directory: ${expectedPostDir}
`;

console.log(testInfoMessage);

beforeEach(() => {
// Ensure the output directory is clean
if (fs.existsSync(mockDir)) {
fs.rmdirSync(mockDir, { recursive: true });
fs.rmSync(mockDir, { recursive: true });
}

// Recreate the output directory
Expand All @@ -55,7 +59,7 @@ describe("End-to-End CLI tests with multiple test files", () => {
afterEach(() => {
// Cleanup the output directory after each test
if (fs.existsSync(mockDir)) {
fs.rmdirSync(mockDir, { recursive: true });
fs.rmSync(mockDir, { recursive: true });
}
});

Expand Down
Loading