chore(tests): migrate shared folder to Vitests (#62270)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
This commit is contained in:
Sem Bauke
2025-09-22 14:50:41 +02:00
committed by GitHub
parent 2eab3662f5
commit 0f0d91f50f
11 changed files with 26 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ module.exports = {
'tools/challenge-parser/', 'tools/challenge-parser/',
'tools/scripts/build/', 'tools/scripts/build/',
'tools/scripts/lint/', 'tools/scripts/lint/',
'shared',
'curriculum', 'curriculum',
'client', 'client',
'shared/' 'shared/'

View File

@@ -70,7 +70,6 @@
"serve:client-ci": "cd ./client && pnpm run serve-ci", "serve:client-ci": "cd ./client && pnpm run serve-ci",
"start": "npm-run-all create:shared -p develop:server serve:client", "start": "npm-run-all create:shared -p develop:server serve:client",
"test": "NODE_OPTIONS='--max-old-space-size=7168' run-s create:shared build:curriculum build-workers test:**", "test": "NODE_OPTIONS='--max-old-space-size=7168' run-s create:shared build:curriculum build-workers test:**",
"test:source": "jest",
"test:api": "cd api && pnpm test", "test:api": "cd api && pnpm test",
"test:tools:challenge-helper-scripts": "cd ./tools/challenge-helper-scripts && pnpm test run", "test:tools:challenge-helper-scripts": "cd ./tools/challenge-helper-scripts && pnpm test run",
"test:tools:scripts-build": "cd ./tools/scripts/build && pnpm test run", "test:tools:scripts-build": "cd ./tools/scripts/build && pnpm test run",
@@ -78,8 +77,9 @@
"test:tools:challenge-parser": "cd ./tools/challenge-parser && pnpm test run", "test:tools:challenge-parser": "cd ./tools/challenge-parser && pnpm test run",
"test:curriculum:content": "cd ./curriculum && pnpm test run", "test:curriculum:content": "cd ./curriculum && pnpm test run",
"test:curriculum:tooling": "cd ./curriculum && pnpm vitest run", "test:curriculum:tooling": "cd ./curriculum && pnpm vitest run",
"test-curriculum-full-output": "cd ./curriculum && pnpm run test:full-output run", "test:shared": "cd ./shared && pnpm vitest run",
"test:client": "cd ./client && pnpm test run", "test:client": "cd ./client && pnpm test run",
"test-curriculum-full-output": "cd ./curriculum && pnpm run test:full-output run",
"test-config": "jest config", "test-config": "jest config",
"test-utils": "jest utils", "test-utils": "jest utils",
"prepare": "husky", "prepare": "husky",

9
pnpm-lock.yaml generated
View File

@@ -779,7 +779,14 @@ importers:
specifier: ^3.2.4 specifier: ^3.2.4
version: 3.2.4(@types/node@20.12.8)(@vitest/ui@3.2.4)(jsdom@16.7.0)(msw@2.8.7(@types/node@20.12.8)(typescript@5.8.2))(terser@5.28.1)(tsx@4.19.1)(yaml@2.8.0) version: 3.2.4(@types/node@20.12.8)(@vitest/ui@3.2.4)(jsdom@16.7.0)(msw@2.8.7(@types/node@20.12.8)(typescript@5.8.2))(terser@5.28.1)(tsx@4.19.1)(yaml@2.8.0)
shared: {} shared:
devDependencies:
'@vitest/ui':
specifier: ^3.2.4
version: 3.2.4(vitest@3.2.4)
vitest:
specifier: ^3.2.4
version: 3.2.4(@types/node@20.12.8)(@vitest/ui@3.2.4)(jsdom@26.1.0)(msw@2.8.7(@types/node@20.12.8)(typescript@5.8.2))(terser@5.28.1)(tsx@4.19.1)(yaml@2.8.0)
tools/challenge-editor/api: tools/challenge-editor/api:
dependencies: dependencies:

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { catalogSuperBlocks } from './curriculum'; import { catalogSuperBlocks } from './curriculum';
import { catalog } from './catalog'; import { catalog } from './catalog';

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { Certification, linkedInCredentialIds } from './certification-settings'; import { Certification, linkedInCredentialIds } from './certification-settings';
describe('linkedInCredentialIds', () => { describe('linkedInCredentialIds', () => {

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { blocklistedUsernames } from './constants'; import { blocklistedUsernames } from './constants';
describe('constants', () => { describe('constants', () => {

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { Languages } from './i18n'; import { Languages } from './i18n';
import { import {
SuperBlocks, SuperBlocks,

View File

@@ -9,6 +9,9 @@
"node": ">=16", "node": ">=16",
"pnpm": ">=10" "pnpm": ">=10"
}, },
"scripts": {
"test": "vitest"
},
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -17,5 +20,9 @@
"bugs": { "bugs": {
"url": "https://github.com/freeCodeCamp/freeCodeCamp/issues" "url": "https://github.com/freeCodeCamp/freeCodeCamp/issues"
}, },
"homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme" "homepage": "https://github.com/freeCodeCamp/freeCodeCamp#readme",
"devDependencies": {
"vitest": "^3.2.4",
"@vitest/ui": "^3.2.4"
}
} }

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { getLines } from './get-lines'; import { getLines } from './get-lines';
const content = 'one\ntwo\nthree'; const content = 'one\ntwo\nthree';

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { createPoly, createSource } from './polyvinyl'; import { createPoly, createSource } from './polyvinyl';
const polyData = { const polyData = {

View File

@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { import {
isValidUsername, isValidUsername,
usernameTooShort, usernameTooShort,