pushkin-consortium / pushkin-exptemplates-basic

Basic jsPsych experiment with a "hello world" timeline.
MIT License
0 stars 6 forks source link

Jest tests #31

Closed jkhartshorne closed 1 year ago

jkhartshorne commented 1 year ago

@hzeng2 @jessestorbeck reminding you of this request. You should be able to test this now.

hzeng2 commented 1 year ago

All tests passed for me, although I needed to install jest-environment-jsdom first, using this command (might be helpful to @jessestorbeck):

yarn add -D jest-environment-jsdom

Below is the test result:

✔ ~/pushkin-exptemplates-basic/web page/src [MASTER L|✚ 2] 19:13 $ npx jest --env=jsdom basic.test.js Browserslist: caniuse-lite is outdated. Please run: npx browserslist@latest --update-db PASS ./basic.test.js ✓ use jsdom in this test file (1 ms) Experiment Timeline ✓ should be an array (1 ms) ✓ should contain at least one trial ✓ should have the correct structure for the hello world trial (2 ms)

Test Suites: 1 passed, 1 total Tests: 4 passed, 4 total Snapshots: 0 total Time: 0.646 s Ran all test suites matching /basic.test.js/i.

jkhartshorne commented 1 year ago

@Weiiirrr -- you should be able to add jest-environment-jsdom to the repo, following your instructions. Can you please make that update, commit, and push before we merge? Thanks!

jkhartshorne commented 1 year ago

@Weiiirrr -- alternatively, see https://github.com/pushkin-consortium/pushkin-exptemplates-reading/pull/2#pullrequestreview-1494349562

jessestorbeck commented 1 year ago

Am I supposed to be able to use this version of the exp template repo in the same way as described in pushkin-consortium/pushkin-sitetemplate-basic#1? Because I am getting the following error:

jessestorbeck@jesses-air-4 pushkin_test % node ../pushkin-cli/build/index.js install experiment ? What do you want to call your experiment? vocab ? Which experiment template do you want to use? path ? What is the absolute path to your experiment template? /Users/jessestorbeck/De sktop/pushkin-exptemplates-basic Making vocab in /Users/jessestorbeck/Desktop/pushkin_test/experiments copying from /Users/jessestorbeck/Desktop/pushkin-exptemplates-basic be patient... Installing dependencies for api controllers Installing dependencies for web page Installing dependencies for worker loaded compFile Building vocab_api from api controllers vocab_api is built vocab_api is published locally via yalc vocab_api added to build cycle via yalc Building worker Writing out front-end config running setEnv() Setting front-end 'environment variable' ... Building front end worker is built Building vocab_web from web page node:internal/errors:862 const err = new Error(message); ^

Error: Command failed: yarn run build error Command "build" not found.

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:511:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5) {

code: 1, killed: false, signal: null, cmd: 'yarn run build', stdout: 'yarn run v1.22.19\n' + 'info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.\n', stderr: 'error Command "build" not found.\n' }

Node.js v20.2.0

hzeng2 commented 1 year ago

Sorry, I realized configuring package.json does not work. I found it as a solution but didn't test it before I suggested we use it. I still have to do the yarn add -D jest-environment-jsdom step just as before. @Weiiirrr -- maybe your suggestion of adding jest-environment-jsdom to the repo works? Also, I am linking these two pr's here: https://github.com/pushkin-consortium/pushkin-exptemplates-reading/pull/2, https://github.com/pushkin-consortium/pushkin-exptemplates-lexical/pull/3, since these three would be solved with the same solution.