Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
03e0be4
fix(testing-mocks): changed to vitest
nsemets Mar 25, 2026
1128446
test(configs): changed configs from jest to vitest
nsemets Mar 30, 2026
275b1dd
test(mocks): updated mocks imports and add new mocks
nsemets Mar 30, 2026
2d91fe8
test(shared): updated tests for shared files
nsemets Mar 30, 2026
2c030aa
test(core): updated tests for core files
nsemets Mar 30, 2026
9ba359c
test(features): updated tests for features(static, search, settings)
nsemets Mar 30, 2026
d07890e
test(registries): updated tests for registries and registry
nsemets Mar 30, 2026
673f805
test(project): updated tests for project
nsemets Mar 30, 2026
a684ef9
test(preprints): updated tests for preprints
nsemets Mar 30, 2026
0f375e1
test(moderation): updated tests for moderation and my projects
nsemets Mar 30, 2026
8ce59ff
test(metadata): updated metadata tests
nsemets Mar 30, 2026
9911614
test(features): updated tests for meetings, institutions and home
nsemets Mar 30, 2026
7ca0e8f
test(features): updated tests for contributors and files
nsemets Mar 30, 2026
7d3edee
test(features): updated tests for analytics, auth and collections
nsemets Mar 30, 2026
3c1f2c7
test(admin-institutions): updated tests
nsemets Mar 31, 2026
006dd25
fix(tests): updated configs and fixed some tests
nsemets Mar 31, 2026
7813ff5
test(fixes): fixed some tests and updated coverage thresholds
nsemets Mar 31, 2026
774a8c4
test(legacy-wiki): updated legacy wiki and added tests
nsemets Mar 31, 2026
f85e09a
test(setup): removed unused files and updated coverage
nsemets Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 0 additions & 17 deletions .github/counter/counter.test.display.js

This file was deleted.

22 changes: 0 additions & 22 deletions .github/counter/counter.test.increment.js

This file was deleted.

13 changes: 6 additions & 7 deletions .github/scripts/check-coverage-thresholds.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const coverage = require('../../coverage/coverage-summary.json');
const jestConfig = require('../../jest.config.js');
const vitestConfig = require('../../vitest.config.ts');

const summary = coverage.total;
const thresholds = jestConfig.coverageThreshold.global;
const thresholds = vitestConfig.default.test.coverage.thresholds;

let failed = false;
const errors = [];
Expand All @@ -28,7 +28,7 @@ for (const key of ['branches', 'functions', 'lines', 'statements']) {
);
errors.push(
formatErrorsWithAlignedStars(
`Please update the coverageThreshold.global.${key} in the jest.config.js to ---> ${current} <---`,
`Please update test.coverage.thresholds.${key} in vitest.config.ts to ---> ${current} <---`,
true
)
);
Expand All @@ -40,9 +40,9 @@ for (const key of ['branches', 'functions', 'lines', 'statements']) {
if (failed) {
const stars = '*'.repeat(warnMessage.length + 8);
console.log('\n\nCongratulations! You have successfully run the coverage check and added tests.');
console.log('\n\nThe jest.config.js file is not insync with your new test additions.');
console.log('Please update the coverage thresholds in jest.config.js.');
console.log('You will need to commit again once you have updated the jst.config.ts file.');
console.log('\n\nThe vitest.config.ts file is not in sync with your new test additions.');
console.log('Please update test.coverage.thresholds in vitest.config.ts.');
console.log('You will need to commit again once you have updated the vitest.config.ts file.');
console.log('This is only necessary until we hit 100% coverage.');
console.log(`\n\n${stars}`);
errors.forEach((err) => {
Expand All @@ -54,5 +54,4 @@ if (failed) {
console.log(`${leftBracket}${warnMessage}${rightBracket}`);
console.log(`${leftBracket}${' '.repeat(warnMessage.length)}${rightBracket}`);
console.log(`${stars}\n\n`);
// process.exit(1);
}
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Jest Tests
name: Run Vitest Tests

on:
pull_request:
Expand Down Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run Jest tests
- name: Run Vitest tests
run: npm run ci:test
test-coverage:
runs-on: ubuntu-latest
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run Jest tests with coverage
- name: Run Vitest tests with coverage
run: npm run ci:test:coverage

- name: Check coverage thresholds
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,23 @@ take up to 60 seconds once the docker build finishes.

## Testing the project

The project uses jest for unit testing.
A "counter" script executes before and after each test run to track how many times the unit
tests are run locally. The output is displayed.
The project uses Vitest through Angular's unit test builder (`ng test`).
A "counter" script displays local run stats after coverage runs.

```bash
npm run test (single test run)
npm run test:watch (single run after file save)
npm run test:coverage (code coverage results)
npm run test # single test run (no watch)
npm run test:one "src/path/to/file.spec.ts" # run one spec file
npm run test:watch # watch mode
npm run test:coverage # coverage reports
```

- all commits must pass the local pipeline for test coverage
Coverage thresholds are configured in `vitest.config.ts` (`test.coverage.thresholds`).
To validate threshold updates after improving coverage:

```bash
npm run test:check-coverage-thresholds
```

- Verifies newly added tests match the thresholds
- This is only used until we hit 100% test coverage
- all commits must pass the local pipeline for test coverage

## Volta

OSF uses volta to manage node and npm versions inside of the repository
Expand Down
19 changes: 15 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"prefix": "osf",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"builder": "@angular/build:application",
"options": {
"outputPath": "dist/osf",
"index": "src/index.html",
Expand Down Expand Up @@ -166,7 +166,7 @@
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"builder": "@angular/build:dev-server",
"options": {
"hmr": false
},
Expand Down Expand Up @@ -196,9 +196,20 @@
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-devkit/build-angular:jest",
"builder": "@angular/build:unit-test",
"options": {
"tsConfig": "tsconfig.spec.json"
"runnerConfig": "vitest.config.ts",
"coverageInclude": ["src/app/**/*.ts"],
"coverageExclude": [
"src/main.ts",
"src/app/app.{config,routes}.ts",
"**/theme/*.ts",
"**/*.{routes,server}.ts",
"**/index.ts",
"**/mappers/**",
"**/constants/**",
"**/*.{enum,model,type,interface}.ts"
]
}
},
"lint": {
Expand Down
Loading
Loading