Skip to content

Conversation

@GP4cK
Copy link
Contributor

@GP4cK GP4cK commented Jun 16, 2021

This PR:

  1. adds Jest as a dependency
  2. adds a very simplistic first test on ThreeUtils.ts
  3. adds a github action to run the test automatically on new PRs

TLDR: as of now, we can't test files that import viewer.ts but we can still test other files.

Explanation:
I wanted to test the Viewer constructor and make sure that it creates a ThreeJs Scene. Unfortunately, it seems that the fact that viewer.js is importing a js file (three/examples/jsm/controls/OrbitControls.js) is causing issues with jest.
The error I get is:

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

I tried a few things but I got stuck.
It ain't much but it's honest work.

EDIT: the tests are now working even with viewer.ts.

Comment on lines +38 to +43
overrides: [{
files: ['*.spec.ts'],
env: {
jest: true,
},
}],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sure that when we are in a file that ends with .spec.ts, we can use the describe, test, expect etc. function without errors from the linter

"module": "ESNext",
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to duplicate this file to set allowJS to true for the tests to run

@agviegas agviegas merged commit f19cdae into ThatOpen:master Jun 18, 2021
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