Skip to content

Commit

Permalink
migrate codemirror-graphql to vitest (#3832)
Browse files Browse the repository at this point in the history
* a

* a
  • Loading branch information
dimaMachina authored Dec 14, 2024
1 parent 04b7695 commit dedb871
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 2 deletions.
1 change: 0 additions & 1 deletion packages/codemirror-graphql/jest.config.js

This file was deleted.

3 changes: 2 additions & 1 deletion packages/codemirror-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"!jest.config.js"
],
"scripts": {
"build": "node ../../scripts/renameFileExtensions.js './esm/{**,!**/__tests__/}/*.js' . .esm.js"
"build": "node ../../scripts/renameFileExtensions.js './esm/{**,!**/__tests__/}/*.js' . .esm.js",
"test": "vitest"
},
"peerDependencies": {
"@codemirror/language": "6.0.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/codemirror-graphql/setup-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @ts-expect-error
document.createRange = function () {
return {
setEnd() {},
setStart() {},
getClientRects() {
return { top: 0, bottom: 0, left: 0, right: 0 };
},
getBoundingClientRect() {
return { right: 0 };
},
};
};
16 changes: 16 additions & 0 deletions packages/codemirror-graphql/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'vitest/config';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./setup-files.ts'],
alias: {
// fixes Duplicate "graphql" modules cannot be used at the same time since different
graphql: require.resolve('graphql'),
},
},
});

0 comments on commit dedb871

Please sign in to comment.