Skip to content

Commit fd21485

Browse files
authored
Smoke tests (#458)
1 parent feac92b commit fd21485

16 files changed

Lines changed: 346 additions & 8 deletions

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ jobs:
5555
- name: Install dependencies
5656
run: pnpm install && pnpm add --global concurrently
5757

58-
- name: Build & Test
58+
- name: Build & Unit Test
5959
run: concurrently --prefix none --group "pnpm:build" "pnpm:test"
6060

61+
- name: Smoke Test
62+
# Don't collect coverage here as it overrides the unit test's coverage
63+
run: pnpm test:smoke --coverage=false
64+
6165
- name: Submit coverage
6266
uses: coverallsapp/github-action@master
6367
continue-on-error: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Outputs
2-
/dist
2+
dist
33

44
# Logs
55
*.log

jest.config.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
/** @type {import('@jest/types').Config.InitialOptions} */
2-
const config = {
1+
// Need to extend from a base config because projects don't inherit configurations as documented
2+
// https://github.com/jestjs/jest/issues/11411
3+
/** @type {import('@jest/types').Config.InitialProjectOptions} */
4+
const baseConfig = {
35
transform: {
4-
'^.+\\.(t|j)sx?$': ['@swc/jest'],
6+
'.*': ['@swc/jest'],
57
},
6-
collectCoverage: true,
7-
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts'],
88
testPathIgnorePatterns: ['/node_modules/', '/dist'],
99
};
1010

11+
/** @type {import('@jest/types').Config.InitialOptions} */
12+
const config = {
13+
collectCoverage: true,
14+
projects: [
15+
{
16+
...baseConfig,
17+
displayName: 'unit',
18+
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts'],
19+
// (src|bin) doesn't seem to work on Windows
20+
testMatch: ['src', 'bin'].map((dir) => `<rootDir>/${dir}/**/*.spec.ts`),
21+
},
22+
{
23+
...baseConfig,
24+
displayName: 'smoke',
25+
testMatch: ['<rootDir>/tests/**/*.spec.ts'],
26+
},
27+
],
28+
};
29+
1130
module.exports = config;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"lint:fix": "pnpm run lint --fix",
3636
"prepublishOnly": "safe-publish-latest && pnpm run build",
3737
"report-coverage": "cat coverage/lcov.info | coveralls",
38-
"test": "jest",
38+
"test": "jest --selectProjects unit",
39+
"test:smoke": "jest --selectProjects smoke",
3940
"prepare": "husky install"
4041
},
4142
"repository": {

tests/cjs-import/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

tests/cjs-import/smoke-test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
import type { ConcurrentlyResult } from 'concurrently';
3+
import concurrently, { concurrently as concurrently2, createConcurrently } from 'concurrently';
4+
5+
const result: ConcurrentlyResult = concurrently(['ls'], {
6+
raw: true,
7+
});
8+
9+
const result2: ConcurrentlyResult = concurrently2(['ls'], {
10+
killOthers: ['failure'],
11+
});
12+
13+
const result3: ConcurrentlyResult = createConcurrently(['ls'], {
14+
successCondition: 'all',
15+
});

tests/cjs-import/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "dist",
4+
"module": "CommonJS",
5+
"moduleResolution": "Node",
6+
"skipLibCheck": true
7+
}
8+
}

tests/cjs-require/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

tests/cjs-require/smoke-test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
3+
import concurrently = require('concurrently');
4+
5+
const { concurrently: concurrently2, createConcurrently } = concurrently;
6+
7+
const result: concurrently.ConcurrentlyResult = concurrently(['ls'], {
8+
raw: true,
9+
});
10+
11+
const result2: concurrently.ConcurrentlyResult = concurrently2(['ls'], {
12+
killOthers: ['failure'],
13+
});
14+
15+
const result3: concurrently.ConcurrentlyResult = createConcurrently(['ls'], {
16+
successCondition: 'all',
17+
});

tests/cjs-require/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "dist",
4+
"module": "CommonJS",
5+
"moduleResolution": "Node",
6+
"skipLibCheck": true
7+
}
8+
}

0 commit comments

Comments
 (0)