Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@luhagel
Copy link
Contributor

@luhagel luhagel commented Aug 5, 2020

Using createTestContext in a monorepo setting leads to the Layout.create function detecting the top level package.json and error out because that one doesn't have it's own name. However, by exposing the projectRoot option already accepted by Layout.create, we can circumvent this by resolving the path ahead of time, i.e.:

Object.assign(ctx, await originalCreateTestContext({ projectRoot: path.join(__dirname, '../..') }))

TODO

  • docs
    • jsdoc
    • website api
    • website guides
    • website tutorial
  • tests

@netlify
Copy link

netlify bot commented Aug 5, 2020

Deploy request for graphql-nexus pending review.

Review with commit 3698db4

https://app.netlify.com/sites/graphql-nexus/deploys

Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

Thanks @luhagel!

One thing. Can you add some jsdoc for this option, mainly about why this setting might be used (like the other).

@luhagel
Copy link
Contributor Author

luhagel commented Aug 7, 2020

Will do

@luhagel luhagel requested a review from jasonkuhrt August 8, 2020 21:59
Copy link
Member

@jasonkuhrt jasonkuhrt left a comment

Choose a reason for hiding this comment

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

Thanks @luhagel!

Clarifying question. The search for package.json starts from cwd by default. If you were inside your package root I don't think there should be any issue, right? However if you're trying to run tests for a package from the monorepo root, then indeed that will not work.

Just want to make sure I'm understanding the problem.

@luhagel
Copy link
Contributor Author

luhagel commented Aug 11, 2020

@jasonkuhrt Exactly, the projectRoot and cwd work as expected if the command is started from the nexus package root.
In our example, we have a monorepo with a few packages of which the api package is one.

Our Jest suite runs from the monorepo root and executes all the suites across all the packages via jest projects.

Since the yarn test command gets kicked off from the monrepo root, cwd resolves to the top level package.json instead of the one in packages/api, which leads to errors to parsing since workspace roots miss some fields and the plugins are defined i the package root so reflection breaks.

@jasonkuhrt jasonkuhrt merged commit ddfe403 into prisma-labs:master Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants