Skip to content

Commit

Permalink
chore: use vitest (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Jul 21, 2024
1 parent c03bc0e commit 76f1ed9
Show file tree
Hide file tree
Showing 7 changed files with 1,704 additions and 4,595 deletions.
6,120 changes: 1,620 additions & 4,500 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 4 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "prettier --check '{src,test}/**/*.ts' README.md package.json",
"lint:fix": "prettier --write '{src,test}/**/*.ts' README.md package.json",
"pretest": "npm run -s lint",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
"test": "vitest run --coverage"
},
"repository": "github:probot/octokit-plugin-config",
"keywords": [
Expand All @@ -22,48 +22,21 @@
"devDependencies": {
"@octokit/core": "^6.0.1",
"@octokit/tsconfig": "^3.0.0",
"@types/jest": "^29.0.0",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.0.0",
"@vitest/coverage-v8": "^2.0.3",
"esbuild": "^0.21.0",
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
"globby": "^14.0.0",
"jest": "^29.0.0",
"prettier": "^3.0.0",
"semantic-release-plugin-update-version-in-files": "^1.1.0",
"strip-indent": "^4.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"vitest": "^2.0.3"
},
"peerDependencies": {
"@octokit/core": ">=5"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.test.json",
"useESM": true
}
]
},
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
},
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
},
"release": {
"branches": [
"+([0-9]).x",
Expand Down
128 changes: 64 additions & 64 deletions test/__snapshots__/get.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`octokit.config.get .json extension: result 1`] = `
exports[`octokit.config.get > .json extension > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand All @@ -19,7 +19,7 @@ exports[`octokit.config.get .json extension: result 1`] = `
}
`;

exports[`octokit.config.get .yaml extension: result 1`] = `
exports[`octokit.config.get > .yaml extension > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand All @@ -38,7 +38,7 @@ exports[`octokit.config.get .yaml extension: result 1`] = `
}
`;

exports[`octokit.config.get _extends file is missing: result 1`] = `
exports[`octokit.config.get > _extends file is missing > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
Expand All @@ -64,7 +64,37 @@ exports[`octokit.config.get _extends file is missing: result 1`] = `
}
`;

exports[`octokit.config.get _extends: base -> _extends: base2: result 1`] = `
exports[`octokit.config.get > _extends: base > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
"setting2": "value from base config file",
},
"files": [
{
"config": {
"setting1": "value from repo config file",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "hello-world",
"url": "https://github.com/gitapi/repos/octocat/hello-world/contents/.github%2Fmy-app.yml",
},
{
"config": {
"setting1": "value from base config file",
"setting2": "value from base config file",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "base",
"url": "https://github.com/gitapi/repos/octocat/base/contents/.github%2Fmy-app.yml",
},
],
}
`;

exports[`octokit.config.get > _extends: base -> _extends: base2 > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
Expand Down Expand Up @@ -106,7 +136,7 @@ exports[`octokit.config.get _extends: base -> _extends: base2: result 1`] = `
}
`;

exports[`octokit.config.get _extends: base with defaults and custom merge: result 1`] = `
exports[`octokit.config.get > _extends: base with defaults and custom merge > result 1`] = `
{
"config": {
"otherSetting1": "value from repo config file",
Expand Down Expand Up @@ -149,37 +179,7 @@ exports[`octokit.config.get _extends: base with defaults and custom merge: resul
}
`;

exports[`octokit.config.get _extends: base: result 1`] = `
{
"config": {
"setting1": "value from repo config file",
"setting2": "value from base config file",
},
"files": [
{
"config": {
"setting1": "value from repo config file",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "hello-world",
"url": "https://github.com/gitapi/repos/octocat/hello-world/contents/.github%2Fmy-app.yml",
},
{
"config": {
"setting1": "value from base config file",
"setting2": "value from base config file",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "base",
"url": "https://github.com/gitapi/repos/octocat/base/contents/.github%2Fmy-app.yml",
},
],
}
`;

exports[`octokit.config.get _extends: base:test.yml: result 1`] = `
exports[`octokit.config.get > _extends: base:test.yml > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
Expand Down Expand Up @@ -209,7 +209,7 @@ exports[`octokit.config.get _extends: base:test.yml: result 1`] = `
}
`;

exports[`octokit.config.get _extends: other-owner/base: result 1`] = `
exports[`octokit.config.get > _extends: other-owner/base > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
Expand Down Expand Up @@ -239,7 +239,7 @@ exports[`octokit.config.get _extends: other-owner/base: result 1`] = `
}
`;

exports[`octokit.config.get _extends: other-owner/base:test.yml: result 1`] = `
exports[`octokit.config.get > _extends: other-owner/base:test.yml > result 1`] = `
{
"config": {
"setting1": "value from repo config file",
Expand Down Expand Up @@ -269,7 +269,7 @@ exports[`octokit.config.get _extends: other-owner/base:test.yml: result 1`] = `
}
`;

exports[`octokit.config.get README simple usage example: result 1`] = `
exports[`octokit.config.get > README simple usage example > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand All @@ -288,7 +288,7 @@ exports[`octokit.config.get README simple usage example: result 1`] = `
}
`;

exports[`octokit.config.get branch option: result 1`] = `
exports[`octokit.config.get > branch option > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand All @@ -307,7 +307,7 @@ exports[`octokit.config.get branch option: result 1`] = `
}
`;

exports[`octokit.config.get config file is empty: result 1`] = `
exports[`octokit.config.get > config file is empty > result 1`] = `
{
"config": {},
"files": [
Expand All @@ -322,7 +322,7 @@ exports[`octokit.config.get config file is empty: result 1`] = `
}
`;

exports[`octokit.config.get config file missing: result 1`] = `
exports[`octokit.config.get > config file missing > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand All @@ -346,7 +346,7 @@ exports[`octokit.config.get config file missing: result 1`] = `
}
`;

exports[`octokit.config.get merges deeply using defaults function: result 1`] = `
exports[`octokit.config.get > merges deeply using defaults function > result 1`] = `
{
"config": {
"otherSetting1": "value from config file",
Expand All @@ -373,54 +373,54 @@ exports[`octokit.config.get merges deeply using defaults function: result 1`] =
}
`;

exports[`octokit.config.get merges defaults option from .github repository: result 1`] = `
exports[`octokit.config.get > merges defaults option > result 1`] = `
{
"config": {
"config": "value from octocat/.github:.github/my-app.yml",
"config": "value from .github/my-app.yml",
"otherConfig": "default value",
},
"files": [
{
"config": null,
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "hello-world",
"url": "https://github.com/gitapi/repos/octocat/hello-world/contents/.github%2Fmy-app.yml",
},
{
"config": {
"config": "value from octocat/.github:.github/my-app.yml",
"config": "value from .github/my-app.yml",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": ".github",
"url": "https://github.com/gitapi/repos/octocat/.github/contents/.github%2Fmy-app.yml",
"repo": "hello-world",
"url": "https://github.com/gitapi/repos/octocat/hello-world/contents/.github%2Fmy-app.yml",
},
],
}
`;

exports[`octokit.config.get merges defaults option: result 1`] = `
exports[`octokit.config.get > merges defaults option from .github repository > result 1`] = `
{
"config": {
"config": "value from .github/my-app.yml",
"config": "value from octocat/.github:.github/my-app.yml",
"otherConfig": "default value",
},
"files": [
{
"config": {
"config": "value from .github/my-app.yml",
},
"config": null,
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": "hello-world",
"url": "https://github.com/gitapi/repos/octocat/hello-world/contents/.github%2Fmy-app.yml",
},
{
"config": {
"config": "value from octocat/.github:.github/my-app.yml",
},
"owner": "octocat",
"path": ".github/my-app.yml",
"repo": ".github",
"url": "https://github.com/gitapi/repos/octocat/.github/contents/.github%2Fmy-app.yml",
},
],
}
`;

exports[`octokit.config.get repo is .github: result 1`] = `
exports[`octokit.config.get > repo is .github > result 1`] = `
{
"config": {},
"files": [
Expand All @@ -435,7 +435,7 @@ exports[`octokit.config.get repo is .github: result 1`] = `
}
`;

exports[`octokit.config.get resolves _extends in .github repository file: result 1`] = `
exports[`octokit.config.get > resolves _extends in .github repository file > result 1`] = `
{
"config": {
"config": "value from octocat/.github:.github/my-second-app.yml",
Expand Down Expand Up @@ -478,7 +478,7 @@ exports[`octokit.config.get resolves _extends in .github repository file: result
}
`;

exports[`octokit.config.get returns defaults option when no config files exist: result 1`] = `
exports[`octokit.config.get > returns defaults option when no config files exist > result 1`] = `
{
"config": {
"comment": "Thank you for creating the issue!",
Expand Down
1 change: 1 addition & 0 deletions test/get.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { Octokit } from "@octokit/core";
import fetchMock from "fetch-mock";
import stripIndent from "strip-indent";
Expand Down
1 change: 1 addition & 0 deletions test/issues.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { Octokit } from "@octokit/core";
import fetchMock from "fetch-mock";

Expand Down
1 change: 1 addition & 0 deletions test/smoke.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { config, composeConfigGet } from "../src/index.js";

describe("Smoke test", () => {
Expand Down
13 changes: 13 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from "vite";

export default defineConfig({
test: {
coverage: {
include: ["src/**/*.ts"],
reporter: ["html"],
thresholds: {
100: true,
},
},
},
});

0 comments on commit 76f1ed9

Please sign in to comment.