Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Get all tests running with ESM. #197

Merged
merged 12 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
auto-install: true
- run: moon ci --color
env:
MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }}
MOON_NODE_VERSION: ${{ matrix.node-version }}
pack:
name: Pack
Expand All @@ -34,6 +35,8 @@ jobs:
with:
auto-install: true
- run: 'moon run :pack --color'
env:
MOONBASE_SECRET_KEY: ${{ secrets.MOONBASE_SECRET_KEY }}
# docs:
# name: Docs
# runs-on: ubuntu-latest
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
- name: Add key to allow access to repository
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
Expand All @@ -32,7 +30,6 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "gh-actions"
yarn install --immutable
yarn run pack
yarn run moon run :pack
cd website
yarn run deploy
2 changes: 0 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
- uses: beemojs/conventional-pr-action@v2
with:
require-multiple-commits: false
Expand Down
20 changes: 19 additions & 1 deletion .moon/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ tasks:
shell: true

build:
command: 'packemon build --addEngines'
command: 'packemon build --addEngines --quiet'
deps:
- '^:build'
inputs:
- '@group(sources)'
- 'package.json'
Expand Down Expand Up @@ -68,6 +70,22 @@ tasks:
args: '--write'
local: true

test:
command: 'vitest run --config @in(0) .'
inputs:
- '/vitest.config.ts'
- '@group(sources)'
- '@group(tests)'
deps:
- 'build'
env:
BOOSTJS_ENV: 'test'

test-cov:
extends: 'test'
args: '--coverage'
local: true

typecheck:
command: 'tsc --build'
inputs:
Expand Down
14 changes: 0 additions & 14 deletions babel.config.js

This file was deleted.

34 changes: 0 additions & 34 deletions jest.config.js

This file was deleted.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"moon": "$(yarn bin moon) --color",
"coverage": "yarn test --coverage",
"docs": "cd website && yarn run start",
"test": "NODE_ENV=test BOOSTJS_ENV=test vitest",
"release": "yarn run pack && yarn run check && lerna-release",
"version": "yarn install && git add yarn.lock",
"packemon": "yarn dlx --package [email protected] --package typescript --quiet packemon"
Expand All @@ -15,19 +14,17 @@
"node": "20.11.0"
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@moonrepo/cli": "^1.21.3",
"@moonrepo/dev": "^2.0.1",
"@types/babel__core": "^7.20.5",
"@types/exit": "^0.1.31",
"@types/fs-extra": "^11.0.1",
"@types/lodash": "^4.14.194",
"@types/lodash-es": "^4.17.12",
"@types/pluralize": "^0.0.29",
"@types/react": "^17.0.58",
"@types/semver": "^7.3.13",
"@types/split": "^1.0.2",
"@types/wrap-ansi": "^3.0.0",
"babel-preset-moon": "^2.0.14",
"@vitest/coverage-v8": "^1.2.2",
"eslint": "^8.56.0",
"eslint-config-moon": "^2.1.1",
"fs-extra": "^11.1.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/__mocks__/term-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function size() {
return { columns: 80, rows: 80 };
}

size.size = size;

module.exports = size;
2 changes: 1 addition & 1 deletion packages/cli/tests/LogBuffer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, vi } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { LogBuffer } from '../src/LogBuffer';

describe('LogBuffer', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/tests/__mocks__/term-size.js

This file was deleted.

18 changes: 9 additions & 9 deletions packages/cli/tests/__snapshots__/Failure.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`<Failure /> doesnt render code frame if a common error 1`] = `
exports[`<Failure /> > doesnt render code frame if a common error 1`] = `
"
 ERROR 

Something is broken!
"
`;

exports[`<Failure /> doesnt render code frame if arg not found 1`] = `
exports[`<Failure /> > doesnt render code frame if arg not found 1`] = `
"
 ERROR 

Flags and short option groups may not use inline values.
"
`;

exports[`<Failure /> reduces command line by half when index appears off screen 1`] = `
exports[`<Failure /> > reduces command line by half when index appears off screen 1`] = `
"
ERROR

Expand All @@ -27,23 +27,23 @@ exports[`<Failure /> reduces command line by half when index appears off screen
"
`;

exports[`<Failure /> renders a common error 1`] = `
exports[`<Failure /> > renders a common error 1`] = `
"
 ERROR 

Something is broken!
"
`;

exports[`<Failure /> renders a parse error 1`] = `
exports[`<Failure /> > renders a parse error 1`] = `
"
 ERROR 

Flags and short option groups may not use inline values.
"
`;

exports[`<Failure /> renders a parse error with a command line 1`] = `
exports[`<Failure /> > renders a parse error with a command line 1`] = `
"
ERROR

Expand All @@ -54,15 +54,15 @@ exports[`<Failure /> renders a parse error with a command line 1`] = `
"
`;

exports[`<Failure /> renders a validation error 1`] = `
exports[`<Failure /> > renders a validation error 1`] = `
"
 ERROR 

Not enough arity arguments.
"
`;

exports[`<Failure /> renders a validation error with a command line 1`] = `
exports[`<Failure /> > renders a validation error with a command line 1`] = `
"
ERROR

Expand Down
12 changes: 6 additions & 6 deletions packages/cli/tests/__snapshots__/Header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`<Header /> renders \`default\` 1`] = `
exports[`<Header /> > renders \`default\` 1`] = `
"
 TITLE 
"
`;

exports[`<Header /> renders \`failure\` 1`] = `
exports[`<Header /> > renders \`failure\` 1`] = `
"
 TITLE 
"
`;

exports[`<Header /> renders \`muted\` 1`] = `
exports[`<Header /> > renders \`muted\` 1`] = `
"
 TITLE 
"
`;

exports[`<Header /> renders \`success\` 1`] = `
exports[`<Header /> > renders \`success\` 1`] = `
"
 TITLE 
"
`;

exports[`<Header /> renders \`warning\` 1`] = `
exports[`<Header /> > renders \`warning\` 1`] = `
"
 TITLE 
"
Expand Down
32 changes: 16 additions & 16 deletions packages/cli/tests/__snapshots__/Help.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`<Help /> commands doesnt render empty commands 1`] = `""`;
exports[`<Help /> > commands > doesnt render empty commands 1`] = `""`;

exports[`<Help /> commands renders commands (stripped) 1`] = `
exports[`<Help /> > commands > renders commands (stripped) 1`] = `
"
COMMANDS

barbar This is a deprecated command with no params. [deprecated]
foo src [dst] This is a normal command with params."
`;

exports[`<Help /> commands renders commands 1`] = `
exports[`<Help /> > commands > renders commands 1`] = `
"
 COMMANDS 

barbar This is a deprecated command with no params. [deprecated]
foo src [dst] This is a normal command with params."
`;

exports[`<Help /> config renders description 1`] = `" I am a command that does cool things."`;
exports[`<Help /> > config > renders description 1`] = `" I am a command that does cool things."`;

exports[`<Help /> config renders description with additional params 1`] = `" I am a command that does cool things. [deprecated]"`;
exports[`<Help /> > config > renders description with additional params 1`] = `" I am a command that does cool things. [deprecated]"`;

exports[`<Help /> config renders description with markdown 1`] = `
exports[`<Help /> > config > renders description with markdown 1`] = `
" This is the top level command description.
All descriptions support markdown like bold, strong, italics, emphasis, and strikethroughs."
`;

exports[`<Help /> options doesnt render empty options 1`] = `""`;
exports[`<Help /> > options > doesnt render empty options 1`] = `""`;

exports[`<Help /> options renders options (stripped) 1`] = `
exports[`<Help /> > options > renders options (stripped) 1`] = `
"
OPTIONS

Expand All @@ -52,7 +52,7 @@ exports[`<Help /> options renders options (stripped) 1`] = `
(default: true)"
`;

exports[`<Help /> options renders options 1`] = `
exports[`<Help /> > options > renders options 1`] = `
"
 OPTIONS 

Expand All @@ -75,9 +75,9 @@ exports[`<Help /> options renders options 1`] = `
(default: true)"
`;

exports[`<Help /> params doesnt render empty params 1`] = `""`;
exports[`<Help /> > params > doesnt render empty params 1`] = `""`;

exports[`<Help /> params renders params (stripped) 1`] = `
exports[`<Help /> > params > renders params (stripped) 1`] = `
"
PARAMS

Expand All @@ -87,7 +87,7 @@ exports[`<Help /> params renders params (stripped) 1`] = `
3 boolean And finally a boolean param. [deprecated]"
`;

exports[`<Help /> params renders params 1`] = `
exports[`<Help /> > params > renders params 1`] = `
"
 PARAMS 

Expand All @@ -97,7 +97,7 @@ exports[`<Help /> params renders params 1`] = `
3 boolean And finally a boolean param. [deprecated]"
`;

exports[`<Help /> renders everything 1`] = `
exports[`<Help /> > renders everything 1`] = `
" I am a command that does cool things.

 USAGE 
Expand Down Expand Up @@ -137,15 +137,15 @@ exports[`<Help /> renders everything 1`] = `
(default: true)"
`;

exports[`<Help /> usage renders usage array 1`] = `
exports[`<Help /> > usage > renders usage array 1`] = `
"
 USAGE 

$ ink foo bar
$ test --foo -b"
`;

exports[`<Help /> usage renders usage string 1`] = `
exports[`<Help /> > usage > renders usage string 1`] = `
"
 USAGE 

Expand Down
Loading
Loading