@altano/vitest-plugins 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @altano/vitest-plugins
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e936f78: removed sideEffects:true from package.json
8
+
9
+ ## 0.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 2266961: fix import extensions for node libraries
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,9 +1,20 @@
1
1
  {
2
2
  "name": "@altano/vitest-plugins",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Custom matchers and snapshot serializers to enhance vitest",
5
+ "homepage": "https://github.com/altano/npm-packages/tree/main/packages/vitest-plugins",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/altano/npm-packages",
9
+ "directory": "packages/vitest-plugins"
10
+ },
11
+ "license": "ISC",
12
+ "author": {
13
+ "name": "Alan Norbauer",
14
+ "email": "altano@gmail.com",
15
+ "url": "https://alan.norbauer.com"
16
+ },
5
17
  "type": "module",
6
- "sideEffects": false,
7
18
  "exports": {
8
19
  "./matchers": {
9
20
  "default": "./src/matchers/setup.ts",
@@ -13,53 +24,40 @@
13
24
  "./serializers": "./src/serializers/setup.ts",
14
25
  "./serializers/*": "./src/serializers/*.ts"
15
26
  },
16
- "author": {
17
- "name": "Alan Norbauer",
18
- "email": "altano@gmail.com",
19
- "url": "https://alan.norbauer.com"
20
- },
21
- "license": "ISC",
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/altano/npm-packages",
25
- "directory": "packages/vitest-plugins"
27
+ "dependencies": {
28
+ "@prettier/sync": "^0.5.2",
29
+ "serialize-error": "^11.0.3",
30
+ "vfile": "^6.0.3",
31
+ "vitest": "^2.1.3"
26
32
  },
27
- "homepage": "https://github.com/altano/npm-packages/tree/main/packages/vitest-plugins",
28
33
  "devDependencies": {
29
- "@mdx-js/mdx": "^2.3.0",
30
- "@prettier/sync": "^0.5.1",
31
- "@types/node": "^20.11.25",
32
- "@vitest/coverage-v8": "^1.4.0",
33
- "@vitest/expect": "^1.4.0",
34
- "@vitest/ui": "^1.4.0",
35
- "eslint": "^8.57.0",
34
+ "@mdx-js/mdx": "^3.1.0",
35
+ "@types/node": "^20.16.5",
36
+ "@vitest/coverage-v8": "^2.1.3",
37
+ "@vitest/expect": "^2.1.3",
38
+ "eslint": "^9.13.0",
36
39
  "mdast-util-mdxjs-esm": "^2.0.1",
37
- "prettier": "^3.2.5",
38
- "typescript": "^5.4.2",
39
- "unified": "^10.1.2",
40
- "vfile": "^5.3.7",
41
- "vite": "^5.2.8",
42
- "vitest": "^1.4.0",
43
- "@altano/tsconfig": "0.0.0",
44
- "eslint-config-altano": "0.0.0"
40
+ "prettier": "^3.3.3",
41
+ "typescript": "^5.6.3",
42
+ "unified": "^11.0.5",
43
+ "vite": "^5.4.10",
44
+ "vitest": "^2.1.3",
45
+ "@altano/tsconfig": "0.0.0"
45
46
  },
46
47
  "publishConfig": {
47
48
  "access": "public"
48
49
  },
49
- "dependencies": {
50
- "serialize-error": "^11.0.3"
51
- },
52
50
  "scripts": {
51
+ "check:types:src": "tsc --noEmit",
52
+ "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
53
53
  "clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
54
54
  "format": "prettier --check src",
55
55
  "format:fix": "prettier --write src",
56
- "lint": "eslint package.json src/**/*.ts*",
56
+ "lint": "eslint",
57
57
  "lint:fix": "TIMING=1 pnpm lint --fix",
58
58
  "lint:timing": "TIMING=1 pnpm lint",
59
- "test:typecheck": "tsc --project ./tests/tsconfig.json --noEmit",
60
- "test:unit": "vitest --run",
61
- "test:unit:watch": "vitest",
62
- "typecheck:src": "tsc --noEmit",
63
- "typecheck:test": "tsc --noEmit --project ./tests/tsconfig.json"
59
+ "test:check:types": "tsc --project ./tests/tsconfig.json --noEmit",
60
+ "test:unit": "FORCE_COLOR=0 vitest --run",
61
+ "test:unit:watch": "vitest"
64
62
  }
65
63
  }
@@ -1,11 +1,11 @@
1
1
  import { expect } from "vitest";
2
2
 
3
- import toBePath from "./toBePath";
4
- import toBeFile from "./toBeFile";
5
- import toBeDirectory from "./toBeDirectory";
6
- import toEqualFile from "./toEqualFile";
7
- import toMatchError from "./toMatchError";
8
- import toThrowErrorMatching from "./toThrowErrorMatching";
3
+ import toBePath from "./toBePath.js";
4
+ import toBeFile from "./toBeFile.js";
5
+ import toBeDirectory from "./toBeDirectory.js";
6
+ import toEqualFile from "./toEqualFile.js";
7
+ import toMatchError from "./toMatchError.js";
8
+ import toThrowErrorMatching from "./toThrowErrorMatching.js";
9
9
 
10
10
  expect.extend({
11
11
  toBePath,
@@ -1,4 +1,4 @@
1
- import type { Matcher } from "./matcher";
1
+ import type { Matcher } from "./matcher.js";
2
2
  import fs from "node:fs";
3
3
 
4
4
  function directoryExists(path: string): boolean {
@@ -1,4 +1,4 @@
1
- import type { Matcher } from "./matcher";
1
+ import type { Matcher } from "./matcher.js";
2
2
  import fs from "node:fs";
3
3
 
4
4
  function fileExists(path: string): boolean {
@@ -1,4 +1,4 @@
1
- import type { Matcher } from "./matcher";
1
+ import type { Matcher } from "./matcher.js";
2
2
  import { realpathSync } from "node:fs";
3
3
 
4
4
  function getRealpath(path: string): string | null {
@@ -1,4 +1,4 @@
1
- import type { Matcher } from "./matcher";
1
+ import type { Matcher } from "./matcher.js";
2
2
  import fs from "node:fs";
3
3
  import crypto from "node:crypto";
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { serializeError } from "serialize-error";
2
- import type { Matcher } from "./matcher";
2
+ import type { Matcher } from "./matcher.js";
3
3
 
4
4
  const toMatchError: Matcher = function (received: Error, expected: unknown) {
5
5
  // If we don't serialize the error before passing it to vitest, vitest will
@@ -1,5 +1,5 @@
1
- import toMatchError from "./toMatchError";
2
- import type { Matcher } from "./matcher";
1
+ import toMatchError from "./toMatchError.js";
2
+ import type { Matcher } from "./matcher.js";
3
3
 
4
4
  const toThrowErrorMatching: Matcher = function (
5
5
  received: () => never,
@@ -14,6 +14,7 @@ interface CustomMatchers<R = unknown> {
14
14
  toThrowErrorMatching(expected: unknown): R;
15
15
  }
16
16
 
17
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
17
18
  declare module "vitest" {
18
19
  interface Assertion<T> extends CustomMatchers<T> {}
19
20
  interface AsymmetricMatchersContaining extends CustomMatchers {}
@@ -0,0 +1,5 @@
1
+ {
2
+ "printWidth": 80,
3
+ "semi": true,
4
+ "trailingComma": "all"
5
+ }
@@ -1,7 +1,7 @@
1
1
  import { expect } from "vitest";
2
2
 
3
- import absolutePathSerializer from "./absolutePath";
3
+ import absolutePathSerializer from "./absolutePath.js";
4
4
  expect.addSnapshotSerializer(absolutePathSerializer);
5
5
 
6
- import vFileSerializer from "./vFile";
6
+ import vFileSerializer from "./vFile.js";
7
7
  expect.addSnapshotSerializer(vFileSerializer);
@@ -1,5 +1,5 @@
1
1
  import prettier from "@prettier/sync";
2
- import prettierConfig from "../../../../.prettierrc.json";
2
+ import prettierConfig from "./.prettierrc.json";
3
3
  import { VFile, type Value as VFileValue } from "vfile";
4
4
  import type { Options } from "prettier";
5
5
  import type { SnapshotSerializer } from "vitest";
@@ -25,7 +25,9 @@ describe("matchers", () => {
25
25
  it("should throw an error when not a directory", () => {
26
26
  expect(() => {
27
27
  expect("face").toBeDirectory();
28
- }).toThrowErrorMatchingInlineSnapshot(`[Error: Received is not a directory (or cannot be accessed by the current user)]`);
28
+ }).toThrowErrorMatchingInlineSnapshot(
29
+ `[Error: Received is not a directory (or cannot be accessed by the current user)]`,
30
+ );
29
31
  });
30
32
  });
31
33
  });
@@ -16,7 +16,9 @@ describe("matchers", () => {
16
16
  const wrongPath = path.join(import.meta.dirname, "..");
17
17
  expect(() => {
18
18
  expect(import.meta.dirname).toBePath(wrongPath);
19
- }).toThrowErrorMatchingInlineSnapshot(`[Error: The realpath of the received path did not match the expected one]`);
19
+ }).toThrowErrorMatchingInlineSnapshot(
20
+ `[Error: The realpath of the received path did not match the expected one]`,
21
+ );
20
22
  });
21
23
  it("should throw an error for a path that isn't accessible", () => {
22
24
  const nonExistentPath = path.join(import.meta.dirname, "face");
@@ -20,7 +20,9 @@ describe("matchers", () => {
20
20
  it("should fail when given a non-existent file", async () => {
21
21
  expect(() => {
22
22
  expect("faaaaaaaaaace").toEqualFile("khaaaaaaaaan");
23
- }).toThrowErrorMatchingInlineSnapshot(`[Error: ENOENT: no such file or directory, open 'faaaaaaaaaace']`);
23
+ }).toThrowErrorMatchingInlineSnapshot(
24
+ `[Error: ENOENT: no such file or directory, open 'faaaaaaaaaace']`,
25
+ );
24
26
  });
25
27
  });
26
28
  });
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
 
3
- import absolutePathSerializer from "../../../src/serializers/absolutePath";
3
+ import absolutePathSerializer from "../../../src/serializers/absolutePath.js";
4
4
  expect.addSnapshotSerializer(absolutePathSerializer);
5
5
 
6
6
  describe("serializers", () => {
package/vitest.config.ts CHANGED
@@ -1,18 +1,11 @@
1
- import { defineProject } from "vitest/config";
1
+ import { defineConfig } from "vitest/config";
2
2
 
3
- export default defineProject({
3
+ export default defineConfig({
4
4
  test: {
5
5
  dir: "tests/unit",
6
6
  coverage: {
7
7
  enabled: true,
8
-
9
- exclude: [
10
- "tests/e2e",
11
- "playwright.config.ts",
12
- ".eslintrc.cjs",
13
- "tests/unit/**/*.benchmark.tsx",
14
- ],
15
-
8
+ include: ["src"],
16
9
  provider: "v8",
17
10
  all: true,
18
11
  clean: true,
package/.eslintrc.cjs DELETED
@@ -1,19 +0,0 @@
1
- module.exports = {
2
- extends: ["altano"],
3
- overrides: [
4
- {
5
- files: ["src/**/!(*.d).{ts,tsx}", "*.config.ts"],
6
- parserOptions: {
7
- project: ["./tsconfig.json"],
8
- tsconfigRootDir: __dirname,
9
- },
10
- },
11
- {
12
- files: ["tests/**/*.ts", "tests/**/*.tsx"],
13
- parserOptions: {
14
- project: ["./tsconfig.json"],
15
- tsconfigRootDir: `${__dirname}/tests/`,
16
- },
17
- },
18
- ],
19
- };
@@ -1,5 +0,0 @@
1
-
2
- > @altano/vitest-plugins@0.1.0 lint /home/runner/work/npm-packages/npm-packages/packages/vitest-plugins
3
- > eslint package.json src/**/*.ts*
4
-
5
- Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.