Skip to content

Commit

Permalink
👷(packaged) Move to Vitest (#5348)
Browse files Browse the repository at this point in the history
**Description**

<!-- Please provide a short description and potentially linked issues
justifying the need for this PR -->

Change our test runner to Vitest.

Jest is great but it's partial support for ESM is putting us in
troubles. As such we passed fast-check to Vitest a while ago and want to
unify all others so that we preserve a unique test runner in our CI.

<!-- * Your PR is fixing a bug or regression? Check for existing issues
related to this bug and link them -->
<!-- * Your PR is adding a new feature? Make sure there is a related
issue or discussion attached to it -->

<!-- You can provide any additional context to help into understanding
what's this PR is attempting to solve: reproduction of a bug, code
snippets... -->

**Checklist** — _Don't delete this checklist and make sure you do the
following before opening the PR_

- [x] The name of my PR follows [gitmoji](https://gitmoji.dev/)
specification
- [x] My PR references one of several related issues (if any)
- [x] New features or breaking changes must come with an associated
Issue or Discussion
- [x] My PR does not add any new dependency without an associated Issue
or Discussion
- [x] My PR includes bumps details, please run `yarn bump` and flag the
impacts properly
- [x] My PR adds relevant tests and they would have failed without my PR
(when applicable)

<!-- More about contributing at
https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md -->

**Advanced**

<!-- How to fill the advanced section is detailed below! -->

- [x] Category: 👷 Build tools & CI
- [x] Impacts: Test runner

<!-- [Category] Please use one of the categories below, it will help us
into better understanding the urgency of the PR -->
<!-- * ✨ Introduce new features -->
<!-- * 📝 Add or update documentation -->
<!-- * ✅ Add or update tests -->
<!-- * 🐛 Fix a bug -->
<!-- * 🏷️ Add or update types -->
<!-- * ⚡️ Improve performance -->
<!-- * _Other(s):_ ... -->

<!-- [Impacts] Please provide a comma separated list of the potential
impacts that might be introduced by this change -->
<!-- * Generated values: Can your change impact any of the existing
generators in terms of generated values, if so which ones? when? -->
<!-- * Shrink values: Can your change impact any of the existing
generators in terms of shrink values, if so which ones? when? -->
<!-- * Performance: Can it require some typings changes on user side?
Please give more details -->
<!-- * Typings: Is there a potential performance impact? In which cases?
-->
  • Loading branch information
dubzzz authored Oct 21, 2024
1 parent 331814a commit f1b49e0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-peas-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fast-check/packaged": patch
---

👷(packaged) Move to Vitest
3 changes: 0 additions & 3 deletions packages/packaged/babel.config.cjs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/packaged/jest.config.js

This file was deleted.

10 changes: 3 additions & 7 deletions packages/packaged/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build-ci": "yarn build",
"build:publish-types": "tsc -p tsconfig.publish.types.json",
"build:publish-esm": "tsc -p tsconfig.publish.json --module es2015 --moduleResolution node",
"test": "yarn node --experimental-vm-modules $(yarn bin jest) --verbose",
"test": "vitest",
"typecheck": "tsc --noEmit"
},
"repository": {
Expand All @@ -38,14 +38,10 @@
"npm-packlist": "^9.0.0"
},
"devDependencies": {
"@babel/core": "^7.25.8",
"@babel/preset-typescript": "^7.25.7",
"@types/jest": "^29.5.13",
"@types/npm-packlist": "^7.0.3",
"@types/npmcli__arborist": "^5.6.11",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"typescript": "~5.6.3"
"typescript": "~5.6.3",
"vitest": "^2.1.3"
},
"keywords": [],
"funding": [
Expand Down
8 changes: 7 additions & 1 deletion packages/packaged/test/packaged.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { describe, it, expect, afterAll } from 'vitest';
import { promises as fs } from 'fs';
import * as path from 'path';
import * as url from 'url';
import { removeNonPublishedFiles } from '../src/packaged';

// @ts-expect-error --module must be higher
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const testDirname = path.join(__dirname, '..', '.test-artifacts');

afterAll(async () => {
await fs.rmdir(testDirname);
});

describe('removeNonPublishedFiles', () => {
it.each`
Expand Down Expand Up @@ -262,7 +268,7 @@ type RunnerFileSystem = {
async function runPackageTest(runner: (fileSystem: RunnerFileSystem) => Promise<void>): Promise<void> {
const initialWorkingDirectory = process.cwd();
const packageName = `random-package-${Date.now().toString(16)}-${Math.random().toString(16).substring(2)}`;
const packagePath = path.join(__dirname, packageName);
const packagePath = path.join(testDirname, packageName);
try {
const fileSystem: RunnerFileSystem = {
packagePath,
Expand Down
7 changes: 7 additions & 0 deletions packages/packaged/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['**/test/*.{test,spec}.?(c|m)[jt]s?(x)'],
},
});
6 changes: 1 addition & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3076,16 +3076,12 @@ __metadata:
version: 0.0.0-use.local
resolution: "@fast-check/packaged@workspace:packages/packaged"
dependencies:
"@babel/core": "npm:^7.25.8"
"@babel/preset-typescript": "npm:^7.25.7"
"@npmcli/arborist": "npm:^8.0.0"
"@types/jest": "npm:^29.5.13"
"@types/npm-packlist": "npm:^7.0.3"
"@types/npmcli__arborist": "npm:^5.6.11"
babel-jest: "npm:^29.7.0"
jest: "npm:^29.7.0"
npm-packlist: "npm:^9.0.0"
typescript: "npm:~5.6.3"
vitest: "npm:^2.1.3"
bin:
packaged: ./bin/packaged.js
languageName: unknown
Expand Down

0 comments on commit f1b49e0

Please sign in to comment.