Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit a293d68

Browse files
committed
Initial commit
0 parents  commit a293d68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+13097
-0
lines changed

.eslintrc.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
extends: [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
9+
"plugin:import/errors",
10+
"plugin:import/warnings",
11+
"plugin:import/typescript",
12+
],
13+
parser: "@typescript-eslint/parser",
14+
parserOptions: {
15+
project: "tsconfig.json",
16+
},
17+
plugins: ["@typescript-eslint", "jest", "import"],
18+
rules: {
19+
curly: ["error", "all"],
20+
eqeqeq: ["error", "always"],
21+
"no-implicit-coercion": ["error"],
22+
// https://github.com/eslint/eslint/blob/master/docs/rules/no-sequences.md#when-not-to-use-it
23+
"no-restricted-syntax": ["error", "SequenceExpression"],
24+
"prefer-const": ["error", { destructuring: "all" }],
25+
"require-await": ["error"],
26+
"@typescript-eslint/no-unused-expressions": ["error"],
27+
"@typescript-eslint/no-unused-vars": [
28+
"error",
29+
{
30+
argsIgnorePattern: "^_",
31+
caughtErrorsIgnorePattern: "^_",
32+
varsIgnorePattern: "^_",
33+
},
34+
],
35+
"@typescript-eslint/no-use-before-define": ["error", { functions: false }],
36+
"@typescript-eslint/strict-boolean-expressions": [
37+
"error",
38+
{
39+
allowString: false,
40+
allowNumber: false,
41+
allowNullableObject: false,
42+
},
43+
],
44+
"@typescript-eslint/switch-exhaustiveness-check": ["error"],
45+
},
46+
overrides: [
47+
{
48+
// Disable some rules that fail for vendored Jest code. If we fix these, it'll be harder to
49+
// merge upstream changes.
50+
files: ["packages/jest-plugin/src/vendored/**/*.ts"],
51+
rules: {
52+
"@typescript-eslint/restrict-plus-operands": "off",
53+
"@typescript-eslint/strict-boolean-expressions": "off",
54+
"@typescript-eslint/unbound-method": "off",
55+
},
56+
},
57+
{
58+
files: ["**/*.test.ts"],
59+
rules: {
60+
// Allow tests to call require() since that's needed for some mocking.
61+
"@typescript-eslint/no-var-requires": "off",
62+
},
63+
},
64+
],
65+
};

.github/workflows/ci.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: CI
2+
3+
# Controls when the workflow will run
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
branches: [ main, unsquashed-private ]
8+
pull_request:
9+
branches: [ main, unsquashed-private ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch: { }
13+
14+
jobs:
15+
check:
16+
name: Typecheck, lint, and audit
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- uses: actions/setup-node@v2
22+
with:
23+
node-version: '16'
24+
cache: yarn
25+
26+
- uses: actions/cache@v2
27+
with:
28+
path: '**/node_modules'
29+
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
30+
31+
- id: install
32+
run: yarn install --immutable
33+
34+
- run: yarn build
35+
36+
- if: ${{ always() && steps.install.outcome == 'success' }}
37+
run: yarn lint
38+
39+
- if: ${{ always() && steps.install.outcome == 'success' }}
40+
run: yarn prettier:check
41+
42+
- if: ${{ always() && steps.install.outcome == 'success' }}
43+
run: yarn audit
44+
45+
jest_integration_tests:
46+
name: "Jest Integration Tests: Jest ${{ matrix.jest }} + Node ${{ matrix.node }}"
47+
runs-on: ubuntu-latest
48+
needs:
49+
# Don't incur the cost of the test matrix if the basic build fails.
50+
- check
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
node:
55+
- 14
56+
- 16
57+
- 18
58+
jest:
59+
- "27.5"
60+
- "27.4"
61+
- "27.3"
62+
- "27.2"
63+
- "27.1"
64+
- "27.0"
65+
- "26.6"
66+
- "26.5"
67+
- "26.4"
68+
- "26.3"
69+
- "26.2"
70+
- "26.1"
71+
- "26.0"
72+
- "25.5"
73+
- "25.4"
74+
- "25.3"
75+
- "25.2"
76+
- "25.1"
77+
78+
steps:
79+
- uses: actions/checkout@v2
80+
81+
- uses: actions/setup-node@v2
82+
with:
83+
node-version: ${{ matrix.node }}
84+
cache: yarn
85+
86+
- uses: actions/cache@v2
87+
with:
88+
path: '**/node_modules'
89+
key: ${{ runner.os }}-node${{ matrix.node }}-jest${{ matrix.jest }}-modules-${{ hashFiles('yarn.lock') }}
90+
91+
- id: install
92+
run: yarn install --immutable
93+
94+
# Since Jest is composed of many packages, we need to make sure that they're all using the
95+
# same major and minor versions. Otherwise, NPM will keep the newer minor versions since
96+
# they're semver-compatible. This script iteratively installs the lowest compatible semver
97+
# version for each package until yarn.lock converges. See the script for some edge cases due
98+
# to missing package versions with certain minor version numbers.
99+
- name: Set Jest version
100+
run: |
101+
yarn set-jest-version ${{ matrix.jest }}
102+
grep --after-context=1 "^\".*jest.*" yarn.lock
103+
104+
- name: Set resolution for chalk to 3.0.0
105+
if: ${{ startsWith(matrix.jest, '25.') }}
106+
run: yarn set resolution "chalk@npm:^3.0.0 || ^4.0.0" 3.0
107+
108+
- run: yarn build
109+
110+
- name: Enable Unflakable dogfooding
111+
run: |
112+
echo "UNFLAKABLE_API_KEY=${{ secrets.UNFLAKABLE_API_KEY }}" >> $GITHUB_ENV
113+
echo "UNFLAKABLE_ENABLED=true" >> $GITHUB_ENV
114+
if: github.event.action != 'pull_request'
115+
116+
- working-directory: packages/jest-plugin/test/integration
117+
env:
118+
DEBUG: unflakable:*
119+
UNFLAKABLE_SUITE_ID: 28UidZ8cSKjRe4g1xkd9EE8noDF
120+
run: yarn test

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# IntelliJ
2+
.idea
3+
*.iml
4+
5+
# yarn v2
6+
**/.yarn/cache
7+
**/.yarn/unplugged
8+
**/.yarn/build-state.yml
9+
**/.yarn/install-state.gz
10+
**/.pnp.*
11+
12+
# Compiled JS
13+
packages/**/dist/
14+
15+
# dependencies
16+
node_modules/
17+
18+
# misc files
19+
*~
20+
.DS_Store

.yarn/releases/yarn-3.2.0.cjs

Lines changed: 785 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
yarnPath: .yarn/releases/yarn-3.2.0.cjs
2+
nodeLinker: node-modules
3+
4+
# By default, publish packages privately to GitHub for internal testing instead of to NPM.
5+
npmScopes:
6+
unflakable:
7+
npmPublishRegistry: https://npm.pkg.github.com
8+
npmPublishAccess: restricted

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Developer Innovations, LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<p align="center">
2+
<a href="https://unflakable.com" target="_blank" rel="noopener" align="center">
3+
<img src="https://github.com/unflakable/unflakable-javascript/blob/main/images/logo.svg?raw=true" width="350" alt="Unflakable" />
4+
</a>
5+
</p>
6+
7+
[![Twitter Follow](https://img.shields.io/twitter/url?label=%40unflakable&style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ffollow%3Fscreen_name%3Dunflakable)](https://twitter.com/intent/follow?screen_name=unflakable)
8+
9+
# Official Unflakable Plugins for JavaScript
10+
11+
This repository contains the official [Unflakable](https://unflakable.com) plugins for JavaScript
12+
and TypeScript.
13+
14+
## Getting Started
15+
16+
Refer to our [Getting Started](https://docs.unflakable.com/getting-started) documentation
17+
for instructions on getting started using Unflakable.
18+
19+
## Jest Plugin
20+
21+
The Jest plugin enables users of the [Jest](https://jestjs.io) JavaScript test framework
22+
to quarantine flaky tests and track test results.
23+
24+
Refer to the [Jest Plugin](https://docs.unflakable.com/plugins/jest) documentation for
25+
complete usage instructions.
26+
27+
### Compatibility
28+
29+
This plugin maintains compatibility with the Jest and Node.js versions listed below:
30+
31+
[![27.0.0+](https://img.shields.io/badge/Jest-27.0.0%2B-C21325?logo=jest&labelColor=white&logoColor=C21325&style=flat-square)](#)
32+
[![26.0.0+](https://img.shields.io/badge/Jest-26.0.0%2B-C21325?logo=jest&labelColor=white&logoColor=C21325&style=flat-square)](#)
33+
[![25.1.0+](https://img.shields.io/badge/Jest-25.1.0%2B-C21325?logo=jest&labelColor=white&logoColor=C21325&style=flat-square)](#)
34+
<br/>
35+
[![18](https://img.shields.io/badge/Node.js-18-339933?logo=node.js&labelColor=white&logoColor=339933&style=flat-square)](#)
36+
[![16](https://img.shields.io/badge/Node.js-16-339933?logo=node.js&labelColor=white&logoColor=339933&style=flat-square)](#)
37+
[![14](https://img.shields.io/badge/Node.js-14-339933?logo=node.js&labelColor=white&logoColor=339933&style=flat-square)](#)
38+
39+
## Contributing
40+
41+
To report a bug or request a new feature, please
42+
[file a GitHub issue](https://github.com/unflakable/unflakable-javascript/issues).
43+
We also welcome pull requests!

babel.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-env node */
2+
module.exports = (api) => {
3+
api.cache.using(() => process.env.NODE_ENV);
4+
return {
5+
presets: [
6+
"@babel/preset-typescript",
7+
// `@babel/preset-env` is used to transpile ES modules to Common JS for
8+
// consumption by Jest during tests:
9+
...(process.env.NODE_ENV === "test"
10+
? [
11+
[
12+
"@babel/preset-env",
13+
{
14+
targets: {
15+
node: "current",
16+
},
17+
},
18+
],
19+
]
20+
: []),
21+
],
22+
};
23+
};

images/logo.svg

Lines changed: 22 additions & 0 deletions
Loading

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"packageManager": "yarn@3.2.0",
3+
"private": true,
4+
"devDependencies": {
5+
"@babel/preset-env": "^7.16.11",
6+
"@babel/preset-typescript": "^7.16.7",
7+
"@types/js-yaml": "^4.0.5",
8+
"@types/node": "npm:^14",
9+
"@typescript-eslint/eslint-plugin": "^5.13.0",
10+
"@typescript-eslint/parser": "^5.13.0",
11+
"eslint": "^8.10.0",
12+
"eslint-plugin-import": "^2.25.4",
13+
"eslint-plugin-jest": "^26.1.1",
14+
"js-yaml": "^4.1.0",
15+
"prettier": "^2.5.1",
16+
"ts-node": "^10.7.0",
17+
"typescript": "4.5.5"
18+
},
19+
"scripts": {
20+
"audit": "yarn npm audit --all --recursive",
21+
"build": "yarn build:plugins && yarn typecheck:scripts && yarn typecheck:tests",
22+
"build:plugins": "yarn workspace @unflakable/js-api build && yarn workspace @unflakable/jest-plugin build",
23+
"typecheck:scripts": "tsc --noEmit scripts/**/*.ts",
24+
"typecheck:tests": "yarn workspace jest-integration typecheck && yarn workspace jest-integration-input typecheck",
25+
"lint": "eslint packages/**/src/*.{ts,js} scripts/**/*.{ts,js}",
26+
"prettier": "prettier --write packages/**/src/*.{ts,js}",
27+
"prettier:check": "prettier --check packages/**/src/*.{ts,js}",
28+
"publish:private": "yarn workspace @unflakable/js-api npm publish && yarn workspace @unflakable/jest-plugin npm publish",
29+
"set-jest-version": "ts-node scripts/set-jest-version.ts"
30+
},
31+
"workspaces": [
32+
"packages/*",
33+
"packages/jest-plugin/test/integration",
34+
"packages/jest-plugin/test/integration-input"
35+
]
36+
}

0 commit comments

Comments
 (0)