Skip to content

Commit

Permalink
Add tests for dist directory and cleanup dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jun 19, 2024
1 parent 9d32da9 commit 5135f28
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 88 deletions.
16 changes: 16 additions & 0 deletions lib/__tests__/dist.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from "node:fs";
import path from "node:path";
import { describe, test } from "vitest";

/** testing tsup example (packages/shared) - make sure it is build before running this test suit
*
* These tests are not included in coverage as they do not invoke the source code directly. However, these tests are very important to ensure that the build outputs in dist directory are behaving as expected.
*/
describe.concurrent("Test plugin with default options in example build with tsup", () => {
const exampleBuildDir = path.resolve(process.cwd(), "..", "packages", "shared", "dist");

test("Should not contain duplicate require statements for a library", ({ expect }) => {
const text = fs.readFileSync(path.resolve(exampleBuildDir, "index.js"), "utf-8");
expect(text.match(/['"]react['"]/)?.length).toBe(1);
});
});
2 changes: 1 addition & 1 deletion lib/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe.concurrent("Test plugin with ESBuild with default options", async () =>
await esbuild.build(options);
});

test(`"use client"; directive should be present in client components`, ({ expect }) => {
test("Should not contain duplicate require statements for a library", ({ expect }) => {
const text = fs.readFileSync(path.resolve(buildDir, "index.js"), "utf-8");
expect(text.match(/['"]react['"]/)?.length).toBe(1);
});
Expand Down
19 changes: 0 additions & 19 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,11 @@
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/jest-presets": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@testing-library/react": "^16.0.0",
"@types/node": "^20.14.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^1.6.0",
"esbuild": "^0.21.5",
"esbuild-plugin-react18-css": "^0.0.4",
"jsdom": "^24.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tiny-glob": "^0.2.9",
Expand All @@ -44,19 +38,6 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
"dependencies": {
"r18gs": "^1.1.2"
},
"peerDependencies": {
"@types/react": "16.8 - 19",
"next": "10 - 15",
"react": "16.8 - 19"
},
"peerDependenciesMeta": {
"next": {
"optional": true
}
},
"funding": [
{
"type": "github",
Expand Down
5 changes: 3 additions & 2 deletions lib/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tsconfigPaths()],
plugins: [tsconfigPaths()],
test: {
environment: "node",
globals: true,
setupFiles: [],
include: ["**/__tests__/**"],
exclude: ["**/__tests__/build/**"],
coverage: {
include: ["src/**"],
reporter: ["text", "json", "clover", "html"],
Expand Down
84 changes: 18 additions & 66 deletions pnpm-lock.yaml

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

0 comments on commit 5135f28

Please sign in to comment.