-
Notifications
You must be signed in to change notification settings - Fork 165
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
Jest.js Configurations #449
Conversation
Jest.js Configurations
Installing Jest.js
Hi @Forchapeatl this is looking great. Before we merge, let's try to add just one test, of something really simple or obvious. Then I can help connect it with GitHub actions and we'll see the green check mark. How does that sound? |
Example test
Hello @jywarren . I have done as requested. Is the |
Hi, it looks great! Just added the command to package.json so it runs in GitHub Actions now! infragram/.github/workflows/tests.yml Line 25 in a69271b
But now it says:
So I think we may need to add jest as a dependency. Yes, look: https://github.com/publiclab/PublicLab.Editor/blob/main/package.json#L65-L66 |
Hmm, ok, it looks like it's running now, but it got stuck on this line: https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:11 |
@@ -4,7 +4,8 @@ | |||
"description": "A minimal core of the Infragram project in JavaScript.", | |||
"main": "dist/infragram.js", | |||
"scripts": { | |||
"build": "grunt build" | |||
"build": "grunt build", | |||
"test": "jest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Forchapeatl I think I have this line wrong. When you ran npm test
i would have guessed it to run this. But maybe I'm wrong and this line was not needed? In any case, can you see how we're actually running in GitHub Actions now, and maybe make a suggestion of how to fix this? Thank you!!! Exciting!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error I see in the log is:
> [email protected] test /home/runner/work/infragram/infragram
> jest
/home/runner/work/infragram/infragram/node_modules/jest-cli/build/cli/index.js:161
if (error?.stack) {
^
SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:[7](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:8)23:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:7[8](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:9)[9](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:10):[10](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:11))
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:[12](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:13))
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/runner/work/infragram/infragram/node_modules/jest-cli/build/index.js:[13](https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:14):12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! Test failed. See above for more details.
Error: Process completed with exit code 1.
Here: https://github.com/publiclab/infragram/runs/8025926511?check_suite_focus=true#step:7:10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jywarren , sorry for the late response. I've been trying to compile some documents from school.
infragram/.github/workflows/tests.yml
Line 21 in 1dabd5c
run: npm install grunt-cli |
could we do a simple npm install
instead ? I think jest is not being installed properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think npm install is automatically run beforehand; that line is only because grunt-cli is not installed as a regular dependency. Previously i was getting something like "no command jest" but now i think jest is being run.
But, now that I look at this:
https://github.com/publiclab/image-sequencer/blob/main/.github/workflows/tests.yml#L74-L75
I think you could be right. I'll try adding grunt-cli
to the devDependencies and then modifying that line to just be npm install
.
added puppeteer dependency downgraded jest version
Add jest and jest-puppeteer to dependencies block
After Puppeteer has been installed
Hi @Forchapeatl just wanted to say i think you're trying everything I would have, good detective work! One clue is, that Here's the line that's failing. Ah - it's this operator - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining Let's check version in the GitHub Actions environment. We are in Node 10 here, should we upgrade it? infragram/.github/workflows/tests.yml Line 11 in 1dabd5c
|
|
Added Presets Ndvi Red, Ndiv Blue with Color
I'll try updating node now! |
Hey, it's working now! Jest tests are definitely running!
OK, let's see what's up with the port 8080 issue. |
Wait in background
removed concurrency
uncomment #modeSwitcher
uncomment G B values
uncomment #colorbar-container
Ah, what did you find? Some of these passed, huh? |
uncommented presets NDVI
uncommented preset_modalInput variable
log CSS styles
Yes , we pass on github actions only when we log the CSS styling infragram/test/ui/presets.test.js Line 39 in a74ce83
I believe it's ready to merge |
Oh... Is it reading the log as the results? By convention, an output of the digit 0 is read as failing, I think? Or is it 1? You can read how some other folks are configuring jest here and some discussion of exit codes: jestjs/jest#9324 But it's a long thread and there are probably better resources for how log statements affect success or failure. I still think the best approach is to closely match an existing jest test suite, like the image sequencer project. Let me take a look at these logs, but can you ask Cess and Tilda for help in the chat as well? Thanks for sticking with this. We're almost there. |
That's strange.
It doesn't error it actually fails. Meaning it successfully runs the whole test but it reads the test output as a failure. Could this have something to do with the asynchronicity of the test? Like, maybe it just waits until the time out, and then fails. But if we add a comment, somehow, it waits long enough? I don't know if that makes any sense. |
console.log(">>>>>>>>>>>>>>>>>>>>>>>> "+ colorbar_containerInput ); | ||
console.log(">>>>>>>>>>>>>>>>>>>>>>>> "+ preset_modalInput ); | ||
|
||
// Check if #colorbar_Container appears |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the logs and try inserting an obvious true assertion like:
expect (true).toBeTrue();
?
Then try one that should fail? I'm worried we aren't actually testing any of these expect lines if it's getting lost waiting for await.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't we supposed to see a confirming output for each of the expect statements?
changed toEqual() to toBe()
@jywarren ,please may I merge this? |
Was it toEqual vs. toBe? Just let me know by commenting when you solve something so I can follow along! Thanks, yes, let's merge it! You go ahead! |
@@ -40,9 +40,9 @@ describe('Presets Raw ', () => { | |||
//console.log(">>>>>>>>>>>>>>>>>>>>>>>> "+ preset_modalInput ); | |||
|
|||
// Check if #colorbar_Container appears | |||
expect(colorbar_containerInput).toEqual('none'); | |||
expect(colorbar_containerInput).toBe('none'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, great catch.
Great job!! |
Jest.js Configurations
Fixes #418 and #448
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
@publiclab/reviewers
for help, in a comment below