Skip to content

Commit

Permalink
test: run unit tests and integration separatly (#167)
Browse files Browse the repository at this point in the history
Due to error on CI, the integration tests failed.
  • Loading branch information
baruchiro authored Feb 21, 2024
1 parent b050730 commit bf9c582
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:

test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18.x]
Expand All @@ -38,4 +39,5 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn
- run: yarn test
- run: yarn test:unit
- run: yarn test:integration
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"scripts": {
"postinstall": "husky install && playwright install --with-deps chromium",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:unit": "cross-env SKIP_INTEGRATION=true node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:integration": "node --experimental-vm-modules node_modules/jest/bin/jest.js tests",
"test:components": "cd tests/components && vite",
"e2e": "yarn build && playwright test",
Expand All @@ -35,6 +36,7 @@
"@types/firefox-webext-browser": "^111.0.1",
"@vitejs/plugin-vue": "^3.2.0",
"@webcomponents/custom-elements": "^1.5.1",
"cross-env": "^7.0.3",
"del": "^7.0.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/background/advisory/snyk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('snyk', () => {
},
maintenance: {
level: expect.stringMatching(/^GOOD|WARNING|BAD$/),
description: 'Inactive',
description: expect.stringMatching(/^Inactive|Sustainable$/),
},
community: {
level: expect.stringMatching(/^GOOD|WARNING|BAD$/),
Expand Down
1 change: 1 addition & 0 deletions tests/real-examples/real-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const fetchWebpage = async (example) => {
};

export const snapshotWebpages = async (force = false) => {
if (process.env.SKIP_INTEGRATION) return;
const existingSnapshots = existsSync(webpageSnapshotsFolder) && readdirSync(webpageSnapshotsFolder).length;
if (!force && existingSnapshots) {
console.log(`snapshot dir '${webpageSnapshotsFolder} exists, not updating snapshots`);
Expand Down
4 changes: 3 additions & 1 deletion tests/stackoverflow.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { describe, expect, jest, test } from '@jest/globals';
import { findRanges } from '../src/content/stackoverflow/finder';
import { readRealExamples, writeResultsSnapshot } from './real-examples/real-examples';

const describeif = process.env.SKIP_INTEGRATION ? describe.skip : describe;

const JEST_DEFAULT_TIMEOUT = 5000;

const htmlParser = new DOMParser();
Expand All @@ -11,7 +13,7 @@ const getElementFromFragment = (fragment) => {
return div.innerHTML;
};

describe('Real Pages', () => {
describeif('Real Pages', () => {
jest.setTimeout(JEST_DEFAULT_TIMEOUT * 2 * 2);

test('Snapshot real StackOverflow pages', async () => {
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,14 @@ cosmiconfig@^7.0.1:
path-type "^4.0.0"
yaml "^1.10.0"

cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
dependencies:
cross-spawn "^7.0.1"

cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down

0 comments on commit bf9c582

Please sign in to comment.