Skip to content

Commit d5b1130

Browse files
authored
ci(tests): separate unit and integration tests in CI pipeline (promptfoo#1849)
1 parent b58eb13 commit d5b1130

File tree

7 files changed

+17
-5
lines changed

7 files changed

+17
-5
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ jobs:
5050
- name: Install Dependencies
5151
run: |
5252
npm ci
53-
5453
- name: Test
55-
run: npm run test --ci --coverage --maxWorkers=2
54+
run: npm run test -- --ci --coverage --maxWorkers=2
5655

5756
- name: Build
5857
run: npm run build
@@ -225,4 +224,4 @@ jobs:
225224
npm ci
226225
227226
- name: Run Integration Tests
228-
run: npx jest integration --coverage
227+
run: npm run test:integration -- --ci --coverage --maxWorkers=2

jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const config: Config = {
1212
testPathIgnorePatterns: [
1313
'.*\\.test\\.tsx$',
1414
'.*\\.integration\\.test\\.ts$',
15-
'\\.integration\\.test\\.ts$',
1615
'<rootDir>/dist',
1716
'<rootDir>/examples',
1817
'<rootDir>/node_modules',

jest.integration.config.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Config } from 'jest';
2+
import baseConfig from './jest.config';
3+
4+
const config: Config = {
5+
...baseConfig,
6+
testPathIgnorePatterns: [...(baseConfig.testPathIgnorePatterns || [])].filter(
7+
(s) => !s.includes('integration'),
8+
),
9+
};
10+
11+
export default config;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"build:watch": "tsc --watch",
4646
"build": "tsc && shx cp src/*.html dist/src && shx cp src/python/wrapper.py dist/src/python && shx mkdir -p dist/src/golang && shx cp src/golang/wrapper.go dist/src/golang && shx rm -rf dist/drizzle && shx cp -r drizzle dist/drizzle && npm run build:app && shx chmod +x dist/src/main.js",
4747
"test": "jest",
48+
"test:integration": "jest --config jest.integration.config.ts integration",
4849
"test:watch": "jest --watch",
4950
"test:app": "npm run test --prefix src/app",
5051
"format": "prettier -w .",

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import invariant from 'tiny-invariant';
22
import assertions from './assertions';
33
import * as cache from './cache';
44
import { evaluate as doEvaluate } from './evaluator';
5+
import logger from './logger';
56
import { runDbMigrations } from './migrate';
67
import Eval from './models/eval';
78
import { readPrompts, readProviderPromptMap } from './prompts';
@@ -61,7 +62,7 @@ async function evaluate(testSuite: EvaluateTestSuite, options: EvaluateOptions =
6162
try {
6263
return PromptSchema.parse(promptInput);
6364
} catch (error) {
64-
console.warn(
65+
logger.warn(
6566
`Prompt input is not a valid prompt schema: ${error}\nFalling back to serialized JSON as raw prompt.`,
6667
);
6768
return {

test/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jest.mock('../src/prompts', () => {
2929
});
3030
jest.mock('../src/telemetry');
3131
jest.mock('../src/util');
32+
jest.mock('../src/logger');
3233

3334
describe('index.ts exports', () => {
3435
const expectedNamedExports = [

0 commit comments

Comments
 (0)