Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoke tests #458

Merged
merged 9 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ jobs:
- name: Install dependencies
run: pnpm install && pnpm add --global concurrently

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

- name: Smoke Test
# Don't collect coverage here as it overrides the unit test's coverage
run: pnpm test:smoke --coverage=false

- name: Submit coverage
uses: coverallsapp/github-action@master
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Outputs
/dist
dist

# Logs
*.log
Expand Down
29 changes: 24 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
// Need to extend from a base config because projects don't inherit configurations as documented
// https://github.com/jestjs/jest/issues/11411
/** @type {import('@jest/types').Config.InitialProjectOptions} */
const baseConfig = {
transform: {
'^.+\\.(t|j)sx?$': ['@swc/jest'],
'.*': ['@swc/jest'],
},
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist'],
};

/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
collectCoverage: true,
projects: [
{
...baseConfig,
displayName: 'unit',
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts'],
// (src|bin) doesn't seem to work on Windows
testMatch: ['src', 'bin'].map((dir) => `<rootDir>/${dir}/**/*.spec.ts`),
},
{
...baseConfig,
displayName: 'smoke',
testMatch: ['<rootDir>/tests/**/*.spec.ts'],
},
],
};

module.exports = config;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"lint:fix": "pnpm run lint --fix",
"prepublishOnly": "safe-publish-latest && pnpm run build",
"report-coverage": "cat coverage/lcov.info | coveralls",
"test": "jest",
"test": "jest --selectProjects unit",
"test:smoke": "jest --selectProjects smoke",
"prepare": "husky install"
},
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions tests/cjs-import/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
15 changes: 15 additions & 0 deletions tests/cjs-import/smoke-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { ConcurrentlyResult } from 'concurrently';
import concurrently, { concurrently as concurrently2, createConcurrently } from 'concurrently';

const result: ConcurrentlyResult = concurrently(['ls'], {
raw: true,
});

const result2: ConcurrentlyResult = concurrently2(['ls'], {
killOthers: ['failure'],
});

const result3: ConcurrentlyResult = createConcurrently(['ls'], {
successCondition: 'all',
});
8 changes: 8 additions & 0 deletions tests/cjs-import/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "CommonJS",
"moduleResolution": "Node",
"skipLibCheck": true
}
}
3 changes: 3 additions & 0 deletions tests/cjs-require/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
17 changes: 17 additions & 0 deletions tests/cjs-require/smoke-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import concurrently = require('concurrently');

const { concurrently: concurrently2, createConcurrently } = concurrently;

const result: concurrently.ConcurrentlyResult = concurrently(['ls'], {
raw: true,
});

const result2: concurrently.ConcurrentlyResult = concurrently2(['ls'], {
killOthers: ['failure'],
});

const result3: concurrently.ConcurrentlyResult = createConcurrently(['ls'], {
successCondition: 'all',
});
8 changes: 8 additions & 0 deletions tests/cjs-require/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "CommonJS",
"moduleResolution": "Node",
"skipLibCheck": true
}
}
3 changes: 3 additions & 0 deletions tests/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
15 changes: 15 additions & 0 deletions tests/esm/smoke-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { ConcurrentlyResult } from 'concurrently';
import concurrently, { concurrently as concurrently2, createConcurrently } from 'concurrently';

const result: ConcurrentlyResult = concurrently(['ls'], {
raw: true,
});

const result2: ConcurrentlyResult = concurrently2(['ls'], {
killOthers: ['failure'],
});

const result3: ConcurrentlyResult = createConcurrently(['ls'], {
successCondition: 'all',
});
7 changes: 7 additions & 0 deletions tests/esm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16"
}
}
8 changes: 8 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"concurrently": "file:.."
},
"scripts": {
"test": "pnpm --prefix .. test -- --selectProjects smoke"
}
}
206 changes: 206 additions & 0 deletions tests/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions tests/smoke-tests.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { exec as originalExec } from 'child_process';
import * as util from 'util';

const exec = util.promisify(originalExec);

beforeAll(async () => {
await exec('pnpm build', { cwd: `${__dirname}/..` });
await exec('pnpm install', { cwd: __dirname });
}, 10000);

it.each(['cjs-import', 'cjs-require', 'esm'])(

Check warning on line 11 in tests/smoke-tests.spec.ts

View workflow job for this annotation

GitHub Actions / Check

Test has no assertions
'%s',
async (project) => {
// Use as separate execs as tsc outputs to stdout, instead of stderr, and so its text isn't shown
await exec(`tsc -p ${project}`, { cwd: __dirname }).catch((err) =>
Promise.reject(err.stdout),
);
await exec(`node ${project}/dist/smoke-test.js`, { cwd: __dirname });
},
10000,
);
Loading