forked from graphql/graphiql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Convert LSP tests to jest from mocha (graphql#871)
- added fix and comment for new failing tests - added assertions for new tests for Jest - switched back to global jest run, 12.8s for all but codemirror! woo! - make sure mocks arent being built by babel as well (fixes warning)
- Loading branch information
Showing
41 changed files
with
598 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
codecov: | ||
notify: | ||
require_ci_to_pass: no | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "30...100" | ||
|
||
status: | ||
project: yes | ||
patch: yes | ||
changes: no | ||
|
||
flags: | ||
graphiql: | ||
paths: | ||
- packages/graphiql/ | ||
graphql-language-service-interface: | ||
paths: | ||
- packages/graphql-language-service-interface/ | ||
graphql-language-service-utils: | ||
paths: | ||
- packages/graphql-language-service-utils/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
verbose: true, | ||
clearMocks: true, | ||
collectCoverage: true, | ||
setupFiles: [path.join(__dirname, '/resources/enzyme.config.js')], | ||
testMatch: [ | ||
'<rootDir>/packages/*/src/**/*-test.js', | ||
'<rootDir>/packages/*/src/**/*.spec.js', | ||
], | ||
transform: { | ||
'^.+\\.jsx?$': require.resolve('./resources/jestBabelTransform'), | ||
}, | ||
testEnvironment: require.resolve('jest-environment-jsdom-global'), | ||
testPathIgnorePatterns: [ | ||
'node_modules', | ||
'dist', | ||
'codemirror-graphql', | ||
], | ||
collectCoverageFrom: [ | ||
'**/src/**/*.{js,jsx}', | ||
'!**/node_modules/**', | ||
'!**/__tests__/**', | ||
'!**/resources/**', | ||
'!packages/codemirrir-graphql/**', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
node_modules/ | ||
coverage/ | ||
/*.js | ||
!.babelrc.js | ||
!babel.config.js | ||
/utils | ||
/variables | ||
/results | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
presets: [ | ||
require.resolve('@babel/preset-env'), | ||
require.resolve('@babel/preset-flow'), | ||
require.resolve('@babel/preset-react'), | ||
], | ||
plugins: [require.resolve('@babel/plugin-proposal-class-properties')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
function bootJSDOM() { | ||
/* eslint-disable no-console, object-shorthand */ | ||
/** | ||
* Copyright (c) 2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
const doc = jsdom; | ||
|
||
// get the window object out of the document | ||
const win = doc.window; | ||
|
||
// set globals for mocha that make access to document and window feel | ||
// natural in the test environment | ||
global.document = win.document; | ||
global.window = win; | ||
|
||
global.document.createRange = function() { | ||
return { | ||
setEnd: function() {}, | ||
setStart: function() {}, | ||
getClientRects: function() { | ||
return { top: 0, bottom: 0, left: 0, right: 0 }; | ||
}, | ||
getBoundingClientRect: function() { | ||
return { right: 0 }; | ||
}, | ||
}; | ||
}; | ||
|
||
// take all properties of the window object and also attach it to the | ||
// mocha global object | ||
propagateToGlobal(win); | ||
|
||
// from mocha-jsdom | ||
// https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80 | ||
function propagateToGlobal(window) { | ||
for (const key in window) { | ||
if (!window.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
if (key in global) { | ||
continue; | ||
} | ||
global[key] = window[key]; | ||
} | ||
} | ||
|
||
const chai = require('chai'); | ||
|
||
const chaiSubset = require('chai-subset'); | ||
chai.use(chaiSubset); | ||
|
||
process.on('unhandledRejection', (error) => { | ||
console.error('Unhandled Promise Rejection:'); | ||
console.error((error && error.stack) || error); | ||
}); | ||
} | ||
|
||
module.exports = bootJSDOM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.