Skip to content

Commit

Permalink
Migrate from Jest to Vitest (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalters512 authored Sep 11, 2024
1 parent 2fcf8f1 commit 44ade6f
Show file tree
Hide file tree
Showing 8 changed files with 761 additions and 2,605 deletions.
9 changes: 0 additions & 9 deletions config/fileTransformer.js

This file was deleted.

30 changes: 0 additions & 30 deletions config/webpack.config.js

This file was deleted.

21 changes: 0 additions & 21 deletions jest.config.js

This file was deleted.

12 changes: 4 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"format:fix": "prettier --write .",
"lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
"lint:fix": "yarn lint --fix",
"test": "jest --no-cache --runInBand --forceExit --detectOpenHandles",
"test:cov": "jest --coverage --no-cache --runInBand --forceExit --detectOpenHandles",
"test": "vitest",
"test:cov": "vitest run --coverage",
"addscope": "node tools/packagejson name @pyroscope"
},
"publishConfig": {
Expand Down Expand Up @@ -55,27 +55,23 @@
"@types/busboy": "^1.5.4",
"@types/debug": "^4.1.7",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.1",
"@types/source-map": "^0.5.7",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^7.10.0",
"@typescript-eslint/parser": "^7.10.0",
"@vitest/coverage-v8": "^2.0.5",
"busboy": "^1.6.0",
"eslint": "^8.5.6",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"express": "^4.18.1",
"husky": "^7.0.2",
"jest": "^27.2.0",
"pinst": "^2.1.6",
"pprof-format": "^2.1.0",
"prettier": "^2.4.0",
"supertest": "^6.2.3",
"ts-jest": "^27.0.5",
"ts-loader": "^9.2.5",
"typescript": "^4.4.3",
"webpack": "^5.52.1",
"webpack-cli": "^4.8.0"
"vitest": "^2.0.5"
},
"engines": {
"node": ">=v18"
Expand Down
2 changes: 2 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import fs from 'node:fs';
import { Profile } from 'pprof-format';
import Pyroscope from '../src';
Expand Down
5 changes: 2 additions & 3 deletions test/middleware.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import Pyroscope from '../src';
import request from 'supertest';
import express from 'express';
Expand All @@ -6,9 +8,6 @@ import express from 'express';
Pyroscope.init();

describe('express middleware', () => {
afterAll(async () => {
await new Promise<void>((resolve) => setTimeout(() => resolve(), 500)); // avoid jest open handle error
});
it('should be a function', () => {
expect(typeof Pyroscope.expressMiddleware).toBe('function');
});
Expand Down
17 changes: 8 additions & 9 deletions test/profiler.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import Pyroscope from '../src';
import express from 'express';
import busboy from 'busboy';
Expand Down Expand Up @@ -114,7 +116,7 @@ describe('common behaviour of profilers', () => {
});
});

it('should allow to call start profiling twice', (done) => {
it('should allow to call start profiling twice', async () => {
// Simulate memory usage
const timer: NodeJS.Timeout = setInterval(() => {
// Use some memory
Expand All @@ -139,16 +141,13 @@ describe('common behaviour of profilers', () => {
});
Pyroscope.startHeapProfiling();
Pyroscope.startHeapProfiling();
(async () => {
await Pyroscope.stopHeapProfiling();
await Pyroscope.stopHeapProfiling();
// And stop it without starting CPU
await Pyroscope.stop();

clearInterval(timer);
await Pyroscope.stopHeapProfiling();
await Pyroscope.stopHeapProfiling();
// And stop it without starting CPU
await Pyroscope.stop();

done();
})();
clearInterval(timer);
});

it('should have dynamic labels on wall profile', (done) => {
Expand Down
Loading

0 comments on commit 44ade6f

Please sign in to comment.