Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO-MERGE] Enhancing createContentDigest tests -- requesting help #9072

Closed
wants to merge 2 commits into from
Closed

[NO-MERGE] Enhancing createContentDigest tests -- requesting help #9072

wants to merge 2 commits into from

Conversation

samscha
Copy link
Contributor

@samscha samscha commented Oct 12, 2018

So I've been trying to update tests to properly utilize createContentDigest (right now only for gatsby-transformer-csv).

I've found a way to do this but it requires a pretty lengthy import. It also requires an import outside of the plugin's root dir.. which I would rather not do (and is probably not going to pass all CI tests).

I'm still pretty new to Gatsby, but what I would want to do is something like have every plugin auto-import the gatsby/src/utils so I can use them in any test file. This may very well exist and I've just missed it these past two days (doh!).

Thanks for reading and any help is appreciated!

Sam

P.S. the snapshot is directly copy-pasta'd from the pre-contentCreateDigest snapshot (this blob)

from
#8992

Ensured this matched test:update snapshot using createContentDigest util
With util createContentDigest for gatsby-transformer-csv
@pieh
Copy link
Contributor

pieh commented Oct 15, 2018

I'm thinking if we should add export to gatsby package with utils that can be used (primarily) for testing - something like:
const { createContentDigest } = require(`gatsby/utils`)
and then add gatsby as devDependency to packages that make use of those utils - this would also allow 3rd party plugins use same tools as plugins in our monorepo. Other utility would be createNodeId (this one is a bit more complicated, as we generate that utility function per package)

What do you think about that?

P.S. the snapshot is directly copy-pasta'd from the pre-contentCreateDigest snapshot

You can run jest locally with -u flag to update snapshots (they are not hand-written). But reverting it back works here, as exactly same contentDigest is being generated

@samscha
Copy link
Contributor Author

samscha commented Oct 15, 2018

I definitely think adding devDependency packages would clean up the import statements (I noticed that other packages were just importing from src/utils like I had done).

I'm not sure how third party plugins import them right now but I'm sure it would definitely tidy up the code!

I think for right now I'll import createContentDigest like other plugins do (and how I've done here) and finish adding the createContentDigest helper to the other plugins and then use the devDependency import if it's been implemented in a future pr.

And thanks for the jest with -u, I'll start doing that now!

@samscha
Copy link
Contributor Author

samscha commented Oct 15, 2018

P.S. but I definitely would be interested in looking at how to implement this after I finish #8992 !

@DSchau
Copy link
Contributor

DSchau commented Feb 27, 2019

@samscha sorry about this--this kinda fell through the cracks!

Would you be interested in signing up for a pairing session and we can get this a little closer to getting merged?

@DSchau DSchau added the status: awaiting author response Additional information has been requested from the author label Feb 27, 2019
@samscha
Copy link
Contributor Author

samscha commented Mar 2, 2019

yes.. 😅

I definitely would be interested in the pairing session. I'll sign up for that!

@KyleAMathews
Copy link
Contributor

This PR was superseded by a newer one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting author response Additional information has been requested from the author
5 participants