Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mxschmitt
Copy link
Collaborator

In the previous release there was a bug, that caused checkDependenices() to return an empty object if no playwright package was found. This resulted to a truthy if condition here:

export const readPackage = async (): Promise<
Packages | typeof IMPORT_KIND_PLAYWRIGHT
> => {
const packagePath = 'package.json'
const absConfigPath = path.resolve(process.cwd(), packagePath)
const packageConfig = await require(absConfigPath)
// for handling the local tests
if (packageConfig.name === 'jest-playwright-preset') {
return IMPORT_KIND_PLAYWRIGHT
}
const playwright =
checkDependencies(packageConfig.dependencies) ||
checkDependencies(packageConfig.devDependencies)
if (!playwright || !Object.keys(playwright).length) {
throw new Error('None of playwright packages was not found in dependencies')
}
return playwright
}

Which cause the following error:

None of playwright packages was not found in dependencies

@coveralls
Copy link

coveralls commented Jun 15, 2020

Pull Request Test Coverage Report for Build 135785839

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 95.238%

Totals Coverage Status
Change from base Build 135653308: 0.2%
Covered Lines: 71
Relevant Lines: 72

💛 - Coveralls

@mxschmitt mxschmitt requested a review from mmarkelov June 15, 2020 08:31
): Packages | typeof IMPORT_KIND_PLAYWRIGHT | null => {
const packages: Packages = {}
if (!dependencies) return null
if (!dependencies || Object.keys(dependencies).length === 0) return null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check on the packages variable instead of the dependencies variable. Since in my case, both are filled but only devDependencies does contain the playwright related packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxschmitt yeah! That's true, but it will cover case when dependencies or devDependencies are defined, but empty. It should return null, and then we can check if they have some of playwright dependencies. So we check length of packages variable in the end. And in readPackage we can check result with null

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now 👍

@mmarkelov mmarkelov merged commit 840a66b into master Jun 15, 2020
@mmarkelov mmarkelov deleted the bugfix/check-dependencies branch June 15, 2020 09:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants