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

[wip] migrate graphql-language-service-server to vitest #3834

Draft
wants to merge 25 commits into
base: react-compiler2
Choose a base branch
from
Draft
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
10 changes: 6 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,13 @@ module.exports = {
'**/__{tests,mocks}__/*.{js,jsx,ts,tsx}',
'**/*.spec.{ts,js.jsx.tsx}',
],
extends: ['plugin:jest/recommended'],
extends: ['plugin:@vitest/legacy-recommended'],
rules: {
'jest/no-conditional-expect': 'off',
'jest/expect-expect': ['error', { assertFunctionNames: ['expect*'] }],
'@vitest/expect-expect': [
'error',
{ assertFunctionNames: ['expect*'] },
],
'@vitest/no-disabled-tests': 'error',
},
},
{
Expand All @@ -435,7 +438,6 @@ module.exports = {
'**/__tests__/**',
'webpack.config.js',
'**/tests/**',
'test.config.js',
'vitest.config.mts',
'setup-files.ts',
],
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/main-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,3 @@ jobs:
~/.cache/Cypress
key: cypress-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile --immutable

jest:
name: Jest Unit Tests
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4

- id: cache-modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: modules-${{ github.sha }}
- run: yarn test --coverage
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info
fail_ci_if_error: true
verbose: true
25 changes: 2 additions & 23 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,6 @@ jobs:
key: modules-${{ github.sha }}
- run: yarn pretty-check

jest:
name: Jest Unit & Integration Tests
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- id: cache-modules
uses: actions/cache@v4
with:
path: |
**/node_modules
key: modules-${{ github.sha }}
- run: yarn test --coverage
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info
fail_ci_if_error: true
verbose: true

vitest:
name: Vitest Unit Tests
runs-on: ubuntu-latest
Expand All @@ -125,7 +104,7 @@ jobs:
with:
key: build-${{ github.sha }}
path: ${{ env.BUILD-CACHE-LIST }}
- run: yarn vitest
- run: yarn test

eslint:
name: ESLint
Expand Down Expand Up @@ -192,7 +171,7 @@ jobs:
name: Canary
runs-on: ubuntu-latest
# ensure the basic checks pass before running the canary
needs: [build, jest, eslint, vitest, e2e]
needs: [build, eslint, vitest, e2e]
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package-lock.json
.eslintcache
.cspellcache

vite.config.d.ts
vitest.config.*.mjs
vite.config.js

.next/
Expand Down
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.idea
npm-debug.log

.babelrc
CONTRIBUTING.md
node_modules
coverage
Expand All @@ -16,5 +15,4 @@ src
packages
packages/graphiql/*.html
cypress.json
babel.config.js
**/*.tsbuildinfo
17 changes: 0 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,6 @@
"sourceMaps": true,
"preLaunchTask": "watch-vscode"
},
{
"type": "node",
"name": "jest watch",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--config",
"jest.config.js",
"--color",
"--runInBand",
"--watch",
"${relativeFile}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "VS Code Exec Extension: Run",
"type": "extensionHost",
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ breaking their implementations.

- `yarn test graphiql` will run all tests for graphiql. You can also run tests
from a workspace, but most tooling is at the root.
- `yarn test --watch` will run `jest` with `--watch`
- `yarn test --watch` will run `vitest` with `--watch`
- `yarn e2e` at the root will run the end-to-end suite
- `yarn start-monaco` will launch `webpack` dev server for the `monaco` editor
example with GitHub API from the root. This is the fastest way to test changes
Expand Down
45 changes: 0 additions & 45 deletions babel.config.js

This file was deleted.

9 changes: 8 additions & 1 deletion examples/graphiql-webpack/babel.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
module.exports = require('../../resources/babel.config');
module.exports = {
sourceMaps: true,
presets: [
[require.resolve('@babel/preset-env')],
require.resolve('@babel/preset-react'),
],
plugins: [require.resolve('@babel/plugin-proposal-class-properties')],
};
1 change: 1 addition & 0 deletions examples/monaco-graphql-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/monaco-graphql-webpack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"composite": true,
"baseUrl": ".",
"strictPropertyInitialization": false,
"types": ["node", "jest"],
"types": ["node"],
"typeRoots": ["../../node_modules/@types", "node_modules/@types"],
"lib": ["dom", "ESNext"],
"moduleResolution": "node"
},
"references": [{ "path": "../../packages/monaco-graphql" }],
"include": ["src"],
"exclude": ["**/__tests__/**", "**/build/**.*", "../../node_modules"]
"exclude": ["**/build/**.*", "../../node_modules"]
}
54 changes: 0 additions & 54 deletions jest.config.base.js

This file was deleted.

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

This file was deleted.

34 changes: 5 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"*.{js,ts,jsx,tsx}": [
"cross-env ESLINT_USE_FLAT_CONFIG=false eslint --cache --fix",
"prettier --write --ignore-path .eslintignore --ignore-path resources/prettierignore",
"jest --passWithNoTests",
"yarn lint-cspell"
],
"*.{md,html,json,css}": [
Expand Down Expand Up @@ -49,7 +48,6 @@
"e2e": "yarn workspace graphiql e2e",
"eslint": "NODE_OPTIONS=--max-old-space-size=4096 ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ignore-path .gitignore --cache .",
"format": "yarn eslint --fix && yarn pretty",
"jest": "jest",
"license-check": "jsgl --local packages/*",
"lint": "yarn eslint && yarn pretty-check && yarn lint-cspell",
"lint-cspell": "cspell --unique --no-progress --no-must-find-files",
Expand All @@ -67,46 +65,28 @@
"repo:fix": "manypkg fix",
"repo:resolve": "node scripts/set-resolution.js",
"t": "yarn test",
"test": "yarn jest",
"test:ci": "yarn build && jest --coverage && yarn vitest",
"test:coverage": "yarn jest --coverage",
"test:watch": "yarn jest --watch",
"test": "yarn wsrun -p -m test",
"test:ci": "yarn build && yarn test --coverage",
"test:coverage": "yarn test --coverage",
"test:watch": "yarn test --watch",
"tsc": "tsc --build",
"vitest": "yarn wsrun -p -m test",
"wsrun:noexamples": "wsrun --exclude-missing --exclude example-monaco-graphql-react-vite --exclude example-monaco-graphql-nextjs --exclude example-monaco-graphql-webpack --exclude example-graphiql-webpack",
"gen-agenda": "wgutils agenda gen"
},
"dependencies": {
"eslint-plugin-react-compiler": "19.0.0-beta-37ed2a7-20241206",
"graphql-http": "^1.22.1",
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-private-methods": "^7.24.7",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
"@babel/register": "^7.21.0",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.7",
"@manypkg/get-packages": "^1.1.3",
"@shopify/eslint-plugin": "^45.0.0",
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
"@types/codemirror": "^0.0.90",
"@types/express": "^4.17.11",
"@types/fetch-mock": "^7.3.2",
"@types/jest": "^29.5.2",
"@types/node": "^16.18.4",
"@types/ws": "8.2.2",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"babel-jest": "^29.4.3",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-transform-import-meta": "^2.2.1",
"concurrently": "^7.0.0",
"copy": "^0.3.2",
"cspell": "^5.15.2",
Expand All @@ -115,7 +95,7 @@
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-cypress": "^4.1.0",
"eslint-plugin-import-x": "^3.1.0",
"eslint-plugin-jest": "^28.6.0",
"@vitest/eslint-plugin": "^1.1.16",
"eslint-plugin-mdx": "^3.1.5",
"eslint-plugin-promise": "^7.0.0",
"eslint-plugin-react": "^7.37.2",
Expand All @@ -124,18 +104,14 @@
"eslint-plugin-sonarjs": "^1.0.4",
"eslint-plugin-unicorn": "^55.0.0",
"execa": "^7.1.1",
"identity-obj-proxy": "^3.0.0",
"fetch-mock": "6.5.2",
"husky": "^4.2.3",
"jest": "^27.5.1",
"js-green-licenses": "4.0.0",
"lint-staged": "^10.1.2",
"mkdirp": "^1.0.4",
"patch-package": "^7.0.2",
"postinstall-postinstall": "^2.1.0",
"prettier": "3.3.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.1.5",
"typedoc": "^0.19.2",
"typescript": "^4.6.3",
"vitest": "^2.1.8",
Expand Down
1 change: 1 addition & 0 deletions packages/cm6-graphql/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('codemirror 6 language', () => {
fs.readFileSync(path.join(caseDir, file), 'utf8'),
file,
)) {
// eslint-disable-next-line @vitest/expect-expect
it(`${name}`, () => {
try {
run(graphqlLanguage.parser);
Expand Down
2 changes: 0 additions & 2 deletions packages/codemirror-graphql/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
babel.config.js
.gitignore
resources
src
Loading
Loading