From c1dbce1cdc5816d9855a7e101cc5440d35ccf832 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Fri, 19 Jul 2024 09:43:24 -0500 Subject: [PATCH] Unit test CI (#29) --- .github/workflows/e2e.yml | 3 ++- .github/workflows/unit.yml | 23 +++++++++++++++++++++++ package.json | 3 ++- src/util/ExtendedMap.spec.ts | 8 ++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/unit.yml diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index cc7f62d3..a425d433 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -16,7 +16,8 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version-file: '.nvmrc' + cache: 'npm' - run: npm ci - name: Run end-to-end tests run: xvfb-run npm run test:e2e diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml new file mode 100644 index 00000000..4dbca586 --- /dev/null +++ b/.github/workflows/unit.yml @@ -0,0 +1,23 @@ +name: Unit Tests +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + unit: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + - run: npm ci + - Run ts checks, linting, and unit tests + run: npm run test:ci diff --git a/package.json b/package.json index 72da171a..ca4bc6ee 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "main": "./out/extension.js", "scripts": { "clean": "rm -rf out", - "test": "npm run ts:build && npm run ts:check && npm run test:lint && npm run test:unit", + "test": "npm run test:ci", + "test:ci": "npm run ts:build && npm run ts:check && npm run test:lint && npm run test:unit", "test:e2e": "npm run ts:build && cd e2e && wdio run ./wdio.conf.ts", "test:lint": "eslint . --ext ts", "test:unit": "vitest", diff --git a/src/util/ExtendedMap.spec.ts b/src/util/ExtendedMap.spec.ts index 859263ff..c2e4791f 100644 --- a/src/util/ExtendedMap.spec.ts +++ b/src/util/ExtendedMap.spec.ts @@ -2,6 +2,14 @@ import { describe, expect, it } from 'vitest'; import { ExtendedMap } from './ExtendedMap'; describe('ExtendedMap Test Suite', () => { + it('CI test', () => { + throw new Error('This is testing CI'); + }); + + it('CI test 2', () => { + expect(4).toBe(5); + }); + it('getOrThrow', () => { const map = new ExtendedMap();