From ce82b392f9efdda2df2295be240f5a6ba3a48780 Mon Sep 17 00:00:00 2001 From: Reuben Ellis Date: Fri, 31 May 2024 10:27:08 -0600 Subject: [PATCH] Updated tests and CI workflows --- .circleci/config.yml | 1 - .github/workflows/chromatic-main-and-prs.yml | 1 - .github/workflows/chromatic-prod.yml | 1 - .github/workflows/chromatic-staging.yml | 1 - .github/workflows/release.yml | 1 - .github/workflows/smoke-test-action.yml | 1 - .github/workflows/smoke-test-node-api.yml | 1 - .github/workflows/smoke-test-node18.yml | 1 - .github/workflows/smoke-test-node20.yml | 1 - .github/workflows/smoke-test-npx.yml | 1 - .github/workflows/smoke-test-windows.yml | 1 - .github/workflows/smoke-test-yarn-berry.yml | 1 - .github/workflows/smoke-test-yarn.yml | 1 - .storybook/preview.tsx | 3 +++ node-src/index.test.ts | 6 +++--- node-src/lib/getDependencies.test.ts | 10 +++++----- 16 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 268455b27..b964af209 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,6 @@ jobs: - v4-dependencies-{{ checksum "yarn.lock" }} - v4-dependencies- - run: corepack use yarn@4.2.2 - - run: yarn set version berry - run: yarn install --immutable - save_cache: diff --git a/.github/workflows/chromatic-main-and-prs.yml b/.github/workflows/chromatic-main-and-prs.yml index 0e32601da..5817a6428 100644 --- a/.github/workflows/chromatic-main-and-prs.yml +++ b/.github/workflows/chromatic-main-and-prs.yml @@ -20,7 +20,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - name: install run: yarn install --immutable - uses: chromaui/action@latest diff --git a/.github/workflows/chromatic-prod.yml b/.github/workflows/chromatic-prod.yml index cd653d7ba..7899172c6 100644 --- a/.github/workflows/chromatic-prod.yml +++ b/.github/workflows/chromatic-prod.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - name: install run: yarn install --immutable - uses: chromaui/action@latest diff --git a/.github/workflows/chromatic-staging.yml b/.github/workflows/chromatic-staging.yml index e9993d6c7..f4a9a9089 100644 --- a/.github/workflows/chromatic-staging.yml +++ b/.github/workflows/chromatic-staging.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - name: install run: yarn install --immutable - uses: chromaui/action-canary@latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 780719809..19f399d14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,6 @@ jobs: - name: Prepare repository run: git fetch --unshallow --tags - run: corepack enable - - run: yarn set version berry - name: Install dependencies run: yarn install --immutable diff --git a/.github/workflows/smoke-test-action.yml b/.github/workflows/smoke-test-action.yml index 0d1df07a2..27009e3d0 100755 --- a/.github/workflows/smoke-test-action.yml +++ b/.github/workflows/smoke-test-action.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - run: yarn - run: yarn build - uses: ./ diff --git a/.github/workflows/smoke-test-node-api.yml b/.github/workflows/smoke-test-node-api.yml index 303e02864..a1831644b 100755 --- a/.github/workflows/smoke-test-node-api.yml +++ b/.github/workflows/smoke-test-node-api.yml @@ -15,7 +15,6 @@ jobs: with: node-version: latest - run: corepack enable - - run: yarn set version berry - run: yarn - run: yarn build - name: run chromatic via node diff --git a/.github/workflows/smoke-test-node18.yml b/.github/workflows/smoke-test-node18.yml index 95aa680e5..262d61f7c 100755 --- a/.github/workflows/smoke-test-node18.yml +++ b/.github/workflows/smoke-test-node18.yml @@ -15,7 +15,6 @@ jobs: with: node-version: 18 - run: corepack enable - - run: yarn set version berry - run: yarn - run: yarn build - uses: ./ diff --git a/.github/workflows/smoke-test-node20.yml b/.github/workflows/smoke-test-node20.yml index c9f808016..33c3d5965 100755 --- a/.github/workflows/smoke-test-node20.yml +++ b/.github/workflows/smoke-test-node20.yml @@ -15,7 +15,6 @@ jobs: with: node-version: 20 - run: corepack enable - - run: yarn set version berry - run: yarn - run: yarn build - uses: ./ diff --git a/.github/workflows/smoke-test-npx.yml b/.github/workflows/smoke-test-npx.yml index dde2ace89..a9db96c92 100644 --- a/.github/workflows/smoke-test-npx.yml +++ b/.github/workflows/smoke-test-npx.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - name: install run: yarn && git status --porcelain - run: yarn build diff --git a/.github/workflows/smoke-test-windows.yml b/.github/workflows/smoke-test-windows.yml index 191c1c0b4..e55489a18 100644 --- a/.github/workflows/smoke-test-windows.yml +++ b/.github/workflows/smoke-test-windows.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - name: install run: yarn && git status --porcelain - name: prep package diff --git a/.github/workflows/smoke-test-yarn-berry.yml b/.github/workflows/smoke-test-yarn-berry.yml index 00fb56897..9b2d851ad 100644 --- a/.github/workflows/smoke-test-yarn-berry.yml +++ b/.github/workflows/smoke-test-yarn-berry.yml @@ -16,7 +16,6 @@ jobs: node-version: lts/* - run: rm -rf subdir # remove conflicting subproject - run: corepack enable - - run: yarn set version berry - name: install run: yarn install env: diff --git a/.github/workflows/smoke-test-yarn.yml b/.github/workflows/smoke-test-yarn.yml index 06c5ef1c5..2b2130cdb 100755 --- a/.github/workflows/smoke-test-yarn.yml +++ b/.github/workflows/smoke-test-yarn.yml @@ -15,7 +15,6 @@ jobs: with: node-version: lts/* - run: corepack enable - - run: yarn set version berry - run: yarn - run: yarn build - run: yarn chromatic --build-script-name build-test-storybook --exit-zero-on-changes --force-rebuild diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index e536209df..3e26ee6ea 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -16,6 +16,9 @@ ansiHTML.setColors({ cyan: '5fb3b2', }); +// @ts-expect-error chalk is not fully typed +chalk.enabled = true; + chalk.level = 3; const codeStyle = { diff --git a/node-src/index.test.ts b/node-src/index.test.ts index 5babee57f..321bb83cd 100644 --- a/node-src/index.test.ts +++ b/node-src/index.test.ts @@ -762,7 +762,7 @@ it('should upload metadata files if --upload-metadata is passed', async () => { expect(upload.mock.calls.at(-1)[1]).toEqual( expect.arrayContaining([ { - contentLength: 742, + contentLength: expect.any(Number), contentType: 'text/typescript', fileKey: '', filePath: '.chromatic/main.ts', @@ -772,7 +772,7 @@ it('should upload metadata files if --upload-metadata is passed', async () => { targetPath: '.chromatic/main.ts', }, { - contentLength: 457, + contentLength: expect.any(Number), contentType: 'application/json', fileKey: '', filePath: '.chromatic/preview-stats.trimmed.json', @@ -782,7 +782,7 @@ it('should upload metadata files if --upload-metadata is passed', async () => { targetPath: '.chromatic/preview-stats.trimmed.json', }, { - contentLength: 1456, + contentLength: expect.any(Number), contentType: 'text/typescript', fileKey: '', filePath: '.chromatic/preview.tsx', diff --git a/node-src/lib/getDependencies.test.ts b/node-src/lib/getDependencies.test.ts index ab9f8246a..5e6e65a33 100644 --- a/node-src/lib/getDependencies.test.ts +++ b/node-src/lib/getDependencies.test.ts @@ -2,7 +2,7 @@ import path from 'path'; import { describe, expect, it } from 'vitest'; import { getDependencies } from './getDependencies'; -import packageJson from '../../package.json'; +import packageJson from '../__mocks__/dependencyChanges/plain-package.json'; import { checkoutFile } from '../git/git'; import TestLogger from './testLogger'; @@ -11,9 +11,9 @@ const ctx = { log: new TestLogger() } as any; describe('getDependencies', () => { it('should return a set of dependencies', async () => { const dependencies = await getDependencies(ctx, { - rootPath: path.join(__dirname, '../../'), - manifestPath: 'package.json', - lockfilePath: 'yarn.lock', + rootPath: path.join(__dirname, '../__mocks__/dependencyChanges'), + manifestPath: 'plain-package.json', + lockfilePath: 'plain-yarn.lock', }); const [dep] = dependencies; @@ -22,7 +22,7 @@ describe('getDependencies', () => { const dependencyNames = Array.from(dependencies).map((dependency) => dependency.split('@@')[0]); expect(dependencyNames).toEqual( expect.arrayContaining([ - ...Object.keys(packageJson.dependencies || {}), + ...Object.keys(packageJson.dependencies), ...Object.keys(packageJson.devDependencies), ]) );