Skip to content

Commit

Permalink
feat: consistent naming (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Sep 23, 2023
1 parent da8bf28 commit 74ebdd3
Show file tree
Hide file tree
Showing 76 changed files with 12,479 additions and 1,909 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,15 @@ jobs:
with:
node-version-file: '.nvmrc'

- name: Setup Jest
run: npm run setup-fixture
env:
JEST_VERSION: ${{ matrix.jest }}
- run: npm -g install yarn

- uses: bahmutov/npm-install@v1
with:
useLockFile: false

- name: Build library
run: npm run build --workspace=jest-metadata

- name: Instrument library
run: npm run instrument --workspace=jest-metadata
- name: Install dependencies
run: yarn

- name: Build fixtures
run: npm run build --workspace=@jest-metadata/recorder
- name: Update fixtures
run: npm run update-fixtures
env:
JEST_VERSION: ${{ matrix.jest }}

- name: Assert no Git changes
run: git diff --exit-code packages/fixtures
Expand All @@ -66,9 +58,10 @@ jobs:
with:
node-version-file: '.nvmrc'

- uses: bahmutov/npm-install@v1
with:
useLockFile: false
- run: npm -g install yarn

- name: Install dependencies
run: yarn

- name: Lint
run: npm run lint:ci
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ jobs:
with:
node-version-file: '.nvmrc'

- uses: bahmutov/npm-install@v1
with:
useLockFile: false
- run: npm -g install yarn

- run: yarn

- name: Lerna Version
run: npx lerna version ${{github.event.release.tag_name}} --no-push --yes --no-git-tag-version
- name: Publish Package
run: |
yarn config set version-tag-prefix "v"
yarn version --new-version "${{ github.event.release.tag_name }}" --no-git-tag-version
yarn publish --non-interactive --access public
- name: Create a commit
uses: EndBug/add-and-commit@v9
with:
message: "chore: release ${{github.event.release.tag_name}}"
new_branch: master
continue-on-error: true

- name: Lerna Publish
run: npx lerna publish from-package --yes
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,13 @@ dist

/__fixtures__/events/
package-lock.json
yarn.lock
.DS_Store

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lerna run lint:staged
yarn workspace jest-metadata lint-staged
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-after-install.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-after-install",
factory: function (require) {
"use strict";var plugin=(()=>{var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var n=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var I=(t,o)=>{for(var e in o)s(t,e,{get:o[e],enumerable:!0})},h=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of x(o))!C.call(t,r)&&r!==e&&s(t,r,{get:()=>o[r],enumerable:!(a=g(o,r))||a.enumerable});return t};var k=t=>h(s({},"__esModule",{value:!0}),t);var P={};I(P,{default:()=>y});var d=n("@yarnpkg/core");var f=n("@yarnpkg/core"),c={afterInstall:{description:"Hook that will always run after install",type:f.SettingsType.STRING,default:""}};var u=n("clipanion"),p=n("@yarnpkg/core");var m=n("@yarnpkg/shell"),l=async(t,o)=>{var r;let e=t.get("afterInstall"),a=!!((r=t.projectCwd)!=null&&r.endsWith(`dlx-${process.pid}`));return e&&!a?(o&&console.log("Running `afterInstall` hook..."),(0,m.execute)(e,[],{cwd:t.projectCwd||void 0})):0};var i=class extends u.Command{async execute(){let o=await p.Configuration.find(this.context.cwd,this.context.plugins);return l(o,!1)}};i.paths=[["after-install"]];var w={configuration:c,commands:[i],hooks:{afterAllInstalled:async(t,o)=>{if((o==null?void 0:o.mode)===d.InstallMode.UpdateLockfile)return;if(await l(t.configuration,!0))throw new Error("The `afterInstall` hook failed, see output above.")}}},y=w;return k(P);})();
return plugin;
}
};
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.3.cjs

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-after-install.cjs
spec: "https://raw.githubusercontent.com/mhassan1/yarn-plugin-after-install/v0.5.0/bundles/@yarnpkg/plugin-after-install.js"

yarnPath: .yarn/releases/yarn-3.6.3.cjs

afterInstall: yarn prepare
146 changes: 145 additions & 1 deletion docs/images/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 17 additions & 15 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,58 @@
## Example suite

```js
const { $Set, $Push } = require('jest-metadata');
const { metadata, $Set, $Push } = require('jest-metadata');

const $Description = (text) => $Set('vendor.description', text);
const $Maintainer = (name, email) => $Set('vendor.maintainer', { name, email });
const $Step = (text) => $Push('vendor.steps', { text, startedAt: now });
const $Label = (value) => $Push(['vendor', 'labels'], value);
const $Flaky = () => $Label('flaky');
const $Maintainer = (name, email) => $Assign('vendor.maintainer', { name, email });
const $Lead = (name, email) => $Merge('vendor.lead', { name, email });
const $Tag = (value) => $Push(['vendor', 'labels'], value);
const $Flaky = () => $Tag('flaky');
const step = (text) => metadata.push('vendor.steps', [{ text, startedAt: now }]);

const actions = require('./actions');

$Maintainer('Jane Smith', 'jane.smith@example.com');
$Lead('Samantha Jones', 'samantha.jones@example.com');
$Description('This is a sample test suite.');
describe('Login flow', () => {
$Description('Prepare the environment');
beforeAll(() => {
$Step('Open the browser');
step('Open the browser');
actions.openBrowser();
});

$Description('Visit the website');
beforeEach(() => {
$Step('Goto the URL: https://example.com');
step('Goto the URL: https://example.com');
actions.goto('https://example.com');
});

$Description('Visit the website');
afterEach(() => {
$Step('Clear cookies');
step('Clear cookies');
actions.clearCookies();
});

$Description('Tear down the environment');
afterAll(() => {
$Step('Close the browser');
step('Close the browser');
actions.closeBrowser();
});

$Label('sanity');
$Tag('sanity');
test('Unhappy scenario', () => {
$Step('Enter invalid credentials');
step('Enter invalid credentials');
actions.sleep(100);
$Step('Assert that the login failed');
step('Assert that the login failed');
});

$Flaky();
$Label('sanity');
$Tag('sanity');
test('Happy scenario', () => {
$Step('Enter valid credentials');
step('Enter valid credentials');
actions.sleep(100);
$Step('Assert that the login succeeded');
step('Assert that the login succeeded');
});
});
```
Expand Down
5 changes: 0 additions & 5 deletions lerna.json

This file was deleted.

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@
"npm": ">=8.0.0"
},
"scripts": {
"prepare": "husky install",
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"clean": "lerna clean",
"lint": "lerna run lint",
"lint:ci": "lerna run lint:ci",
"test": "lerna run test",
"prepare": "husky install || true",
"build": "yarn workspaces foreach run build",
"lint": "yarn workspaces foreach run lint",
"lint:ci": "yarn workspaces foreach run lint:ci",
"test": "yarn workspaces foreach run test",
"setup-fixture": "node scripts/setup-fixture.mjs",
"update-fixtures": "scripts/update-fixtures.sh"
},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"cz-conventional-changelog": "^3.3.0",
"husky": "^8.0.3",
"lerna": "^6.5.1"
"husky": "^8.0.3"
},
"workspaces": [
"packages/*"
]
],
"packageManager": "yarn@3.6.3"
}
2 changes: 1 addition & 1 deletion packages/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"devDependencies": {
"cross-env": "^7.0.3",
"jest": "latest",
"jest-metadata": "^1.0.0-beta.18"
"jest-metadata": "workspace:*"
},
"scripts": {
"bench:dev": "npm run build --workspace=jest-metadata && npm run bench",
Expand Down
10 changes: 0 additions & 10 deletions packages/fixtures/27.x.x/env-worker-1/aggregatedResult.json

This file was deleted.

122 changes: 122 additions & 0 deletions packages/fixtures/27.x.x/env-worker-1/globalMetadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
},
{
"type": "set_metadata",
"testFilePath": "",
"targetId": "globalMetadata",
"path": "vendor.tests",
"value": [
"+"
],
"operation": "push"
}
]
10 changes: 0 additions & 10 deletions packages/fixtures/27.x.x/env-worker-N/aggregatedResult.json

This file was deleted.

Loading

0 comments on commit 74ebdd3

Please sign in to comment.