Skip to content

Commit d45e988

Browse files
Shared configs tests (#125)
* add coverage badge * update release script * update readme * use shared biome config in template * fix cache error. * Update README.md Co-authored-by: Copilot <[email protected]> * Update README.md Co-authored-by: Copilot <[email protected]> * remove redundant workflow. * update readme * update workflow * better conditional handling * add getPackagePath helper * remove extra log * add run to all. * let vitest handle logging * add tree walk to coverage * update test confis * correct JSONPath * initial test config setup * fix tree walking for multiple dirs * disable workspace warning * lint * add packages/apps support * sort cases * slice args * slice args * loop on test all * add plugins to coverage * add more default sources * add subtotals * add exports for tests * udate deps * expand file inclusions * plugin.loader tests * revert loader to cjs --------- Co-authored-by: Copilot <[email protected]>
1 parent d5df244 commit d45e988

36 files changed

+1071
-365
lines changed

.github/copilot-instructions.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Project Overview
2+
3+
## Technologies Used
4+
5+
This project is a monorepo with shared configs exported from the root package.json. It is built using modern technologies and follows best practices for accessibility, performance, and maintainability. The workspace root package (`@instructure.ai/shared-configs`) provides orchestration for the monorepo and handles creating packages. Each package in ./packages or ./apps and ./ (root package) should be treated in isolation. The project is set up with [Vite](https://vite.dev/guide/) for fast development and build times, [Biome](https://biomejs.dev/guides/getting-started/) for code quality and formatting, and [Vitest](https://vitest.dev/guide/) for testing. Do not try to install alternative versions of packages such as es-lint, prettier, or jest. Use the tools provided by the shared-configs package.
6+
7+
## Coding Standards
8+
9+
You should use the provided script and utilities from the root package to build your application. Prefer vite-node over node, shell/bash or other libraries. ESM is the preferred module type and cjs is not necessary. Follow the coding standards and best practices outlined in the documentation to ensure consistency and maintainability. Prefer functional components and hooks over class components. Use TypeScript for type safety and improved developer experience. Prefer built-ins over recommending new dependencies. Ensure your code is well-documented and includes comments where necessary. Always write tests.

.template/shared/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Logs
21
logs
32
*.log
43
npm-debug.log*
@@ -10,7 +9,9 @@ lerna-debug.log*
109
node_modules
1110
dist-ssr
1211
dist
13-
coverage
12+
pub
13+
coverage/*
14+
!coverage.yml
1415
*.local
1516

1617
.idea
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { name as workspaceName } from "../../../package.json" with { type: "json" };
3+
import { name } from "../package.json" with { type: "json" };
4+
5+
describe('package.json', () => {
6+
it('Package name should start with workspace prefix', () => {
7+
expect(workspaceName.split('/')[0]).toBe(name.split('/')[0]);
8+
});
9+
});

.template/shared/tests/package.test.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

.template/shared/vitest.config.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import baseConfig from "@instructure.ai/shared-configs/vitest";
21
import { mergeConfig } from "vitest/config";
2+
import { fileURLToPath } from "node:url";
3+
import path from "node:path";
4+
import baseConfig from "@instructure.ai/shared-configs/vitest";
35

4-
export default mergeConfig(baseConfig, {
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
57

8+
export default mergeConfig(baseConfig, {
9+
root: __dirname,
610
});

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"source.action.useSortedKeys.biome": "explicit",
77
"source.action.useSortedProperties.biome": "explicit"
88
},
9-
"typescript.experimental.useTsgo": true
9+
"typescript.experimental.useTsgo": true,
10+
"vitest.disableWorkspaceWarning": true
1011
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Configs and dev dependencies are shared from the root package `@instructure.ai/s
77

88
## @instructure.ai/shared-configs
99

10-
![Version](https://img.shields.io/github/package-json/version/instructure/instructure.ai?labelColor=%230E1721&color=%234279B6) ![NPM Builds](https://img.shields.io/github/actions/workflow/status/instructure/instructure.ai/release-package.yml?logo=npm&logoColor=%23CB3837&label=package%20builds&labelColor=%230E1721) ![Web Builds](https://img.shields.io/github/actions/workflow/status/instructure/instructure.ai/deploy-apps.yml?logo=javascript&logoColor=%23F7DF1E&label=web%20builds&labelColor=%230E1721) ![Code Coverage](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Finstructure%2Finstructure.ai%2Frefs%2Fheads%2Fmain%2Fcoverage%2Fcoverage.yml&query=coverage.total&logo=vitest&logoColor=%236E9F18&label=coverage&labelColor=%230E1721&color=%234279B6)
10+
![Version](https://img.shields.io/github/package-json/version/instructure/instructure.ai?labelColor=%230E1721&color=%234279B6) ![NPM Builds](https://img.shields.io/github/actions/workflow/status/instructure/instructure.ai/release-package.yml?logo=npm&logoColor=%23CB3837&label=package%20builds&labelColor=%230E1721) ![Web Builds](https://img.shields.io/github/actions/workflow/status/instructure/instructure.ai/deploy-apps.yml?logo=javascript&logoColor=%23F7DF1E&label=web%20builds&labelColor=%230E1721) ![Code Coverage](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Finstructure%2Finstructure.ai%2Frefs%2Fheads%2Fmain%2Fcoverage%2Fcoverage.yml&query=coverage.totals.total&logo=vitest&logoColor=%236E9F18&label=coverage&labelColor=%230E1721&color=%234279B6)
1111

1212
`@instructure.ai/shared-configs` is the root package of this monorepo and provides package templates, workspace utilities, and base configurations.
1313

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { describe, it, expect } from 'vitest';
2+
import { name as workspaceName } from "../../../package.json" with { type: "json" };
3+
import { name } from "../package.json" with { type: "json" };
24

3-
describe('Package exists', () => {
4-
it('should return true', () => {
5-
expect(true).toBe(true);
5+
describe('package.json', () => {
6+
it('Package name should start with workspace prefix', () => {
7+
expect(workspaceName.split('/')[0]).toBe(name.split('/')[0]);
68
});
79
});
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
import baseConfig from "@instructure.ai/shared-configs/vitest";
21
import { mergeConfig } from "vitest/config";
2+
import { fileURLToPath } from "node:url";
3+
import path from "node:path";
4+
import baseConfig from "@instructure.ai/shared-configs/vitest";
5+
6+
const __dir = path.dirname(fileURLToPath(import.meta.url));
7+
const __cdir = path.resolve(__dir, "coverage");
38

4-
export default mergeConfig(baseConfig,{
5-
6-
});
9+
export default mergeConfig(baseConfig, {
10+
root: __dirname,
11+
test: {
12+
coverage: {
13+
reportsDirectory: __cdir,
14+
}
15+
}
16+
});

apps/roadmap/tests/package.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { describe, it, expect } from 'vitest';
2+
import { name as workspaceName } from "../../../package.json" with { type: "json" };
3+
import { name } from "../package.json" with { type: "json" };
24

3-
describe('Package exists', () => {
4-
it('should return true', () => {
5-
expect(true).toBe(true);
5+
describe('package.json', () => {
6+
it('Package name should start with workspace prefix', () => {
7+
expect(workspaceName.split('/')[0]).toBe(name.split('/')[0]);
68
});
79
});

0 commit comments

Comments
 (0)