Skip to content

Commit

Permalink
refactor: Cleanup dependency calculation (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed May 5, 2020
1 parent c2b55ab commit 207b3c4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ let hasTestingLibrary = false

try {
const pkg = readPkgUp.sync({normalize: true})
// eslint-disable-next-line prefer-object-spread
const allDeps = Object.assign(
pkg.peerDependencies,
pkg.devDependencies,
pkg.dependencies,
)
hasJestDom = allDeps.hasOwnProperty('@testing-library/jest-dom')
hasTestingLibrary =
allDeps.hasOwnProperty('@testing-library/dom') ||
allDeps.hasOwnProperty('@testing-library/react') ||
allDeps.hasOwnProperty('@testing-library/angular') ||
allDeps.hasOwnProperty('@testing-library/vue')
const allDeps = Object.keys({
...pkg.peerDependencies,
...pkg.devDependencies,
...pkg.dependencies,
})

hasJestDom = allDeps.includes('@testing-library/jest-dom')
hasTestingLibrary = [
'@testing-library/dom',
'@testing-library/react',
'@testing-library/angular',
'@testing-library/vue',
].some(dependency => allDeps.includes(dependency))
} catch (error) {
// ignore error
}
Expand Down

0 comments on commit 207b3c4

Please sign in to comment.