From 1be114af541475b259792c58b2feabdbde034c86 Mon Sep 17 00:00:00 2001 From: David Paul Graham <43794491+dpgraham4401@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:20:40 -0400 Subject: [PATCH] Fix asynchronous tests (#165) * downgrade jsdom * use consistent checkout and setup node actions * remove caches from github actions workflows * use string template literals in our test component to ensure new line characters are not causing our test to fail * adjust wait for calls in useFetchConfig spec file * Revert "downgrade jsdom" This reverts commit 0fa9aafe5a045026d71b9faf0d1c867729b319dc. * increment docker metadata action version usage * increment package version --- .github/workflows/build-image.yaml | 4 +-- .github/workflows/coverage.yaml | 5 ++-- .github/workflows/dependency-review.yaml | 2 +- .github/workflows/deploy-dev.yaml | 1 - .github/workflows/test.yaml | 25 +++++++--------- package-lock.json | 4 +-- package.json | 2 +- .../useFetchConfig/useFetchConfig.spec.tsx | 29 ++++++++----------- 8 files changed, 30 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index 84b14cb..b6aa5eb 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -26,11 +26,11 @@ jobs: working-directory: . steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Docker meta' id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/${{ inputs.image_name }} tags: ${{ inputs.image_tags }} diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index ea57716..6331dc7 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -2,7 +2,7 @@ name: 'Coverage' on: release: - types: [published] + types: [ published ] jobs: report: @@ -12,13 +12,12 @@ jobs: steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Setup Node.js' uses: actions/setup-node@v4 with: node-version: '20' - cache: 'npm' - name: 'Install dependencies' run: npm ci diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/dependency-review.yaml index 5f193b6..2000ac9 100644 --- a/.github/workflows/dependency-review.yaml +++ b/.github/workflows/dependency-review.yaml @@ -19,7 +19,7 @@ jobs: if: github.repository == 'usepa/haztrak' steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Dependency Review' uses: actions/dependency-review-action@v3 diff --git a/.github/workflows/deploy-dev.yaml b/.github/workflows/deploy-dev.yaml index 45ad63f..81b91e1 100644 --- a/.github/workflows/deploy-dev.yaml +++ b/.github/workflows/deploy-dev.yaml @@ -32,7 +32,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 - cache: 'npm' - name: 'Install dependencies' run: npm ci diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fa5ca5f..2f6d890 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,9 +3,9 @@ name: 'Tests' on: pull_request: - branches: ['main'] + branches: [ 'main' ] push: - branches-ignore: ['main'] + branches-ignore: [ 'main' ] workflow_call: jobs: @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20] + node-version: [ 20 ] steps: - name: 'Checkout' uses: actions/checkout@v4 @@ -23,7 +23,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - name: 'Install Dependencies' run: npm ci @@ -38,17 +37,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20] + node-version: [ 20 ] steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Setup Node' - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - name: 'Install Dependencies' run: npm ci @@ -61,11 +58,11 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Docker meta' id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/the-manifest-game @@ -83,14 +80,12 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout' - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 'Setup Node' - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - name: 'Install Dependencies' run: npm ci diff --git a/package-lock.json b/package-lock.json index bcfa236..be5dc5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "the-manifest-game", - "version": "0.9.4", + "version": "0.9.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "the-manifest-game", - "version": "0.9.4", + "version": "0.9.5", "dependencies": { "@dagrejs/dagre": "^1.1.4", "dompurify": "^3.1.6", diff --git a/package.json b/package.json index 4bf1788..d5cbf47 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "the-manifest-game", "private": true, - "version": "0.9.4", + "version": "0.9.5", "type": "module", "scripts": { "dev": "vite", diff --git a/src/hooks/useFetchConfig/useFetchConfig.spec.tsx b/src/hooks/useFetchConfig/useFetchConfig.spec.tsx index 411a216..143ebcc 100644 --- a/src/hooks/useFetchConfig/useFetchConfig.spec.tsx +++ b/src/hooks/useFetchConfig/useFetchConfig.spec.tsx @@ -1,7 +1,7 @@ import '@testing-library/jest-dom'; import { cleanup, render, screen, waitFor } from '@testing-library/react'; import { useFetchConfig } from 'hooks/useFetchConfig/useFetchConfig'; -import { http, HttpResponse } from 'msw'; +import { delay, http, HttpResponse } from 'msw'; import { setupServer } from 'msw/node'; import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest'; @@ -37,14 +37,12 @@ const TestComponent = () => { {config ? Object.values(config).map((item) => (