Skip to content

add lit-element #2

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add lit-element #2

wants to merge 2 commits into from

Conversation

bennypowers
Copy link

Note: jest needs some encouragement to import javascript modules from other javascript modules.

Note: jest needs some encouragement to import javascript modules from other javascript modules.
@kentcdodds
Copy link
Owner

Thanks! I'm not sure what's up with Travis. Is this working for you locally?

Also, I just want to make sure. Are you cool with this? 173e638

If not then feel free to close the PR, that's fine.

@bennypowers
Copy link
Author

bennypowers commented Sep 16, 2018

No, jest pukes on the lit-html module, which is just a JavaScript module, then complains that is not real js. 🤷‍♂️. Stay classy, Babel.

@bennypowers
Copy link
Author

And yeah you can use this example in your course

@kentcdodds
Copy link
Owner

babel doesn't transpile files found in node_modules by default. Do they have a commonjs version of the module? Otherwise we'll probably have to add a babel.config.js file which will allow us to configure transpiling node_modules files. I think that'd work, though I'm not 100% certain. Could you look into what it takes to make lit-html work with jest?

@bennypowers
Copy link
Author

Could you run Jest with esm?

@kentcdodds
Copy link
Owner

Maybe! You could probably just add an import of esm at the top of your test file. Give it a try!

@bennypowers
Copy link
Author

Ok last commit wrangles jest with modules, but it's not pretty.

more info:
Seems like the official line is that everyone wants it but it's not ready yet
jestjs/jest#4842 (comment)

There's an example here: https://github.com/kenotron/esm-jestwhich requires swapping out the test runner.

https://github.com/web-padawan/lit-components/ are using karma with babel transforms, should work out of the box with -r esm

I've used tape in the past with -r esm and it was a dream.

New Problem

document is not defined. Going to look into this a bit.

@kentcdodds
Copy link
Owner

Maybe this will help? https://github.com/kenotron/esm-jest

@bennypowers
Copy link
Author

The problem is deeper than than, we need a way to mock the browser in jest

justin fagnani over in the polymer slack suggested using puppeteer instead of jest. that would be a major change, but might be worth your considering, especially since the first word in the project title is dom ;)

@kentcdodds
Copy link
Owner

we need a way to mock the browser in jest

Jest does this by default with jsdom (that's what all the other frameworks are relying on).

justin fagnani over in the polymer slack suggested using puppeteer instead of jest

Nope. I don't think it's necessary to use puppeteer. All the other frameworks are working fine with the current setup with jest and jsdom. We'll need to figure out how to make this work with the current setup. I don't think adding puppeteer is necessary at all.

Base automatically changed from master to main January 25, 2021 23:13
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