Skip to content

Commit

Permalink
feat(testing-tools): Added testing-tools library for common test func…
Browse files Browse the repository at this point in the history
…tionality
  • Loading branch information
sullivanpj committed Nov 7, 2023
1 parent 9ac8497 commit 08d3ccd
Show file tree
Hide file tree
Showing 19 changed files with 416 additions and 654 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@
"create-storm-workspace": "workspace:*",
"@storm-software/workspace-tools": "workspace:*",
"@storm-software/linting-tools": "workspace:*",
"@storm-software/git-tools": "workspace:*"
"@storm-software/git-tools": "workspace:*",
"@storm-software/testing-tools": "workspace:*"
},
"patchedDependencies": {
"semantic-release-plugin-decorators@3.0.1": "patches/semantic-release-plugin-decorators@3.0.1.patch",
"semantic-release@22.0.7": "patches/semantic-release@22.0.7.patch"
}
}
},
"triggerEmptyDevReleaseByIncrementingThisNumber": 0
}
10 changes: 10 additions & 0 deletions packages/linting-tools/src/tsconfig/tsconfig.root.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"strictNullChecks": true,
"allowJs": true,
"strict": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"types": ["node", "jest"],
Expand All @@ -19,6 +23,12 @@
"skipLibCheck": true,
"skipDefaultLibCheck": true
},
"ts-node": {
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true
}
},
"include": ["./reset.d.ts"],
"exclude": ["**/node_modules", "**/tmp"]
}
146 changes: 146 additions & 0 deletions packages/testing-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<!-- START header -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->


<div align="center"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-banner.png" width="100%" altText="Storm Software" /></div>

<div align="center">
<a href="https://stormsoftware.org" target="_blank">Website</a> | <a href="https://stormsoftware.org/contact" target="_blank">Contact</a> | <a href="https://github.com/storm-software/stormstack" target="_blank">Repository</a> | <a href="https://stormstack.github.io/stormstack/" target="_blank">Documentation</a> | <a href="https://github.com/storm-software/stormstack/issues/new?assignees=&labels=bug&template=bug-report.yml&title=Bug Report%3A+">Report a Bug</a> | <a href="https://github.com/storm-software/stormstack/issues/new?assignees=&labels=enhancement&template=feature-request.yml&title=Feature Request%3A+">Request a Feature</a> | <a href="https://github.com/storm-software/stormstack/issues/new?assignees=&labels=documentation&template=documentation.yml&title=Documentation Request%3A+">Request Documentation</a> | <a href="https://github.com/storm-software/stormstack/discussions">Ask a Question</a>
</div>

<br />
This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages include CLI utility applications, tools, and various libraries used to create modern, scalable web applications.
<br />

<h3 align="center">💻 Visit <a href="https://stormsoftware.org" target="_blank">stormsoftware.org</a> to stay up to date with this developer</h3><br />

[![Version](https://img.shields.io/badge/version-0.0.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;
[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with docusaurus](https://img.shields.io/badge/documented_with-docusaurus-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://docusaurus.io/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/storm-ops/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)

<h3 align="center" bold="true">⚠️ <b>Attention</b> ⚠️ - This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be availible through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.</h3><br />


<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- END header -->

# Storm Testing Tools

This package contains various testing tools used by Storm workspaces to drive unit and e2e testing. The following packages are included and combined into an easy to use CLI tool:

- [Jest](https://jestjs.io/)
- [Vitest](https://vitest.dev/)
- [Cypress](https://www.cypress.io/)

<!-- START doctoc -->
<!-- END doctoc -->

## Building

Run `nx build testing-tools` to build the library.

## Running unit tests

Run `nx test testing-tools` to execute the unit tests via [Jest](https://jestjs.io).

<!-- START footer -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->


## Storm Workspaces

Storm workspaces are built using <a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools for monorepos, which helps you develop like Google, Facebook, and Microsoft. Building on top of Nx, the Open System provides a set of tools and patterns that help you scale your monorepo to many teams while keeping the codebase maintainable.

## Roadmap

See the [open issues](https://github.com/storm-software/stormstack/issues) for a list of proposed features (and known issues).

- [Top Feature Requests](https://github.com/storm-software/stormstack/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc) (Add your votes using the 👍 reaction)
- [Top Bugs](https://github.com/storm-software/stormstack/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc) (Add your votes using the 👍 reaction)
- [Newest Bugs](https://github.com/storm-software/stormstack/issues?q=is%3Aopen+is%3Aissue+label%3Abug)

## Support

Reach out to the maintainer at one of the following places:

- [Contact](https://stormsoftware.org/contact)
- [GitHub discussions](https://github.com/storm-software/stormstack/discussions)
- <support@stormsoftware.org>

## License

This project is licensed under the **Apache License 2.0**. Feel free to edit and distribute this template as you like.

See [LICENSE](LICENSE) for more information.

## Changelog

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md) file

## Contributing

First off, thanks for taking the time to contribute! Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are **greatly appreciated**.

Please try to create bug reports that are:

- _Reproducible._ Include steps to reproduce the problem.
- _Specific._ Include as much detail as possible: which version, what environment, etc.
- _Unique._ Do not duplicate existing opened issues.
- _Scoped to a Single Bug._ One bug per report.

Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).

You can use [markdownlint-cli](https://github.com/storm-software/stormstack/markdownlint-cli) to check for common markdown style inconsistency.

## Contributors

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://www.sullypat.com/"><img src="https://avatars.githubusercontent.com/u/99053093?v=4?s=100" width="100px;" alt="Patrick Sullivan"/><br /><sub><b>Patrick Sullivan</b></sub></a><br /><a href="#design-sullivanpj" title="Design">🎨</a> <a href="https://github.com/storm-software/storm-ops/commits?author=sullivanpj" title="Code">💻</a> <a href="#tool-sullivanpj" title="Tools">🔧</a> <a href="https://github.com/storm-software/storm-ops/commits?author=sullivanpj" title="Documentation">📖</a> <a href="https://github.com/storm-software/storm-ops/commits?author=sullivanpj" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://tylerbenning.com/"><img src="https://avatars.githubusercontent.com/u/7265547?v=4?s=100" width="100px;" alt="Tyler Benning"/><br /><sub><b>Tyler Benning</b></sub></a><br /><a href="#design-tbenning" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://stormsoftware.org"><img src="https://avatars.githubusercontent.com/u/149802440?v=4?s=100" width="100px;" alt="Stormie"/><br /><sub><b>Stormie</b></sub></a><br /><a href="#maintenance-stormie-bot" title="Maintenance">🚧</a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="center" size="13px" colspan="7">
<img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
<a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
</img>
</td>
</tr>
</tfoot>
</table>

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

<br />
<br />
<div align="center">
<img src="https://pub-e71cff0f90204755bc910518d63cacf8.r2.dev/logo-opengraph.gif" width="100%"/>
</div>
<div align="center">
<a href="https://www.patsullivan.org" target="_blank">Website</a> | <a href="https://www.patsullivan.org/contact" target="_blank">Contact</a> | <a href="https://linkedin.com/in/patrick-sullivan-865526b0" target="_blank">LinkedIn</a> | <a href="https://medium.com/@pat.joseph.sullivan" target="_blank">Medium</a> | <a href="https://github.com/sullivanpj" target="_blank">GitHub</a> | <a href="https://keybase.io/sullivanp" target="_blank">OpenPGP Key</a>
</div>

<div align="center">
<p><b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D</p>
</div>

<h3 align="center">💻 Visit <a href="https://www.patsullivan.org" target="_blank">patsullivan.org</a> to stay up to date with this developer</h3><br /><br />


<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- END footer -->
46 changes: 46 additions & 0 deletions packages/testing-tools/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { FlatCompat } = require("@eslint/eslintrc");
const baseConfig = require("../../eslint.config.js");
const js = require("@eslint/js");
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
});
module.exports = [
...baseConfig,
{
files: [
"packages/testing-tools/**/*.ts",
"packages/testing-tools/**/*.tsx",
"packages/testing-tools/**/*.js",
"packages/testing-tools/**/*.jsx"
],
parserOptions: { project: ["packages/testing-tools/tsconfig.*?.json"] },
rules: {}
},
{
files: [
"packages/testing-tools/**/*.ts",
"packages/testing-tools/**/*.tsx"
],
rules: {}
},
{
files: [
"packages/testing-tools/**/*.js",
"packages/testing-tools/**/*.jsx"
],
rules: {}
},
...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({
...config,
"files": ["packages/testing-tools/**/*.json"],
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"]
}
]
}
}))
];
11 changes: 11 additions & 0 deletions packages/testing-tools/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: "testing-tools",
preset: "../../jest.preset.js",
testEnvironment: "node",
transform: {
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
},
moduleFileExtensions: ["ts", "js", "html"],
coverageDirectory: "../../coverage/packages/testing-tools"
};
39 changes: 39 additions & 0 deletions packages/testing-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@storm-software/testing-tools",
"version": "0.0.1",
"private": false,
"description": "⚡ A package containing various testing tools used by Storm workspaces to drive unit and e2e testing.",
"keywords": [
"storm",
"storm-ops",
"stormstack",
"storm-stack",
"sullivanpj",
"open-system",
"monorepo"
],
"homepage": "https://stormsoftware.org",
"bugs": {
"url": "https://github.com/storm-software/storm-ops/issues",
"email": "support@stormsoftware.org"
},
"repository": {
"type": "github",
"url": "https://github.com/storm-software/storm-ops.git",
"directory": "packages/testing-tools"
},
"license": "Apache License 2.0",
"author": {
"name": "Storm Software",
"email": "contact@stormsoftware.org",
"url": "https://stormsoftware.org"
},
"type": "commonjs",
"main": "./index.cjs",
"dependencies": {
"@nx/jest": "17.0.3"
},
"publishConfig": {
"access": "public"
}
}
56 changes: 56 additions & 0 deletions packages/testing-tools/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "testing-tools",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/testing-tools/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/testing-tools",
"main": "packages/testing-tools/src/index.ts",
"tsConfig": "packages/testing-tools/tsconfig.lib.json",
"project": "packages/testing-tools/package.json",
"deleteOutputPath": true,
"bundle": true,
"sourcemap": false,
"minify": false,
"skipTypeCheck": false,
"thirdParty": true,
"format": ["cjs", "esm"],
"external": [
"@swc/wasm",
"@swc/core",
"nx",
"@angular-devkit/architect"
],
"assets": [
{
"input": "packages/testing-tools",
"glob": "README.md",
"output": "/"
},
{
"input": "packages/testing-tools",
"glob": "CHANGELOG.md",
"output": "/"
},
{
"input": "",
"glob": "LICENSE",
"output": "/"
},
{
"input": "packages/testing-tools/src",
"glob": "jest/**/*.*",
"output": "."
}
]
}
},
"lint": {},
"test": {}
},
"tags": ["type:util", "scope:tools"]
}
1 change: 1 addition & 0 deletions packages/testing-tools/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./jest/config";
1 change: 1 addition & 0 deletions packages/testing-tools/src/jest/__mocks__/file.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test-file-stub";
1 change: 1 addition & 0 deletions packages/testing-tools/src/jest/__mocks__/style.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
* Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
* executed files with coverage collection statements, it may significantly slow down your tests. Default: false
*/
collectCoverage: true,
collectCoverage: process.env.CI ? true : false,

/**
* An array of glob patterns indicating a set of files for which coverage information should be collected.
Expand Down Expand Up @@ -53,13 +53,14 @@ export default {
* A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
* Default: ["json", "lcov", "text"]
*/
coverageReporters: ["lcov"],
coverageReporters: ["lcov", "json"],

setupFiles: ["@storm-software/jest/mocks/jest.setup.js"],
setupFiles: ["@storm-software/testing-tools/jest/__mocks__/jest.setup.js"],

moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"@storm-software/jest/mocks/file.mock.js",
"\\.(css|less)$": "@storm-software/jest/mocks/style.mock.js"
"@storm-software/testing-tools/jest/__mocks__/file.mock.js",
"\\.(css|less)$":
"@storm-software/testing-tools/jest/__mocks__/style.mock.js"
}
};
9 changes: 9 additions & 0 deletions packages/testing-tools/src/jest/file-transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require("path");

module.exports = {
process(sourceText, sourcePath, options) {
return {
code: `module.exports = ${JSON.stringify(path.basename(sourcePath))};`
};
}
};
Loading

0 comments on commit 08d3ccd

Please sign in to comment.