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

Implemented Data Editor Svelte Test Structure #917

Merged
merged 1 commit into from
Jan 1, 2024

Conversation

stricklandrbls
Copy link
Collaborator

  • Added yarn script to run data editor tests using Mocha.
  • Added example function and Svelte store tests.

This is a simple directory structure and test suite setup that utilizes the mocha test suite that's currently a utilized dependency. The test:svelte script should be ran manually during development and is not currently implemented to be ran during packaging of the extension.

With the mocha -w option, it does not currently support traditional sourcing of the directory due a discrepancy with with node. 1 Typing r s <Enter>, while the test:svelte script is watching, will manually source the directory structure and re-run the tests. 2

Closes #915

Footnotes

  1. https://mochajs.org/#nodejs-native-esm-support

  2. https://mochajs.org/#-watch-w

@stricklandrbls stricklandrbls added enhancement New feature or request build Issues related to building of the code typescript code quality Issues related to code quality data editor Issues related to the Data Editor capability configuration issues related to configuration labels Dec 7, 2023
@stricklandrbls stricklandrbls added this to the 1.4.0 milestone Dec 7, 2023
@stricklandrbls stricklandrbls self-assigned this Dec 7, 2023
@stricklandrbls stricklandrbls force-pushed the setup-svelte-test-env branch 2 times, most recently from dadc36d to 09c40e9 Compare December 8, 2023 18:31
package.json Outdated
@@ -41,6 +41,7 @@
"package": "run-func build/yarn-scripts.ts package && yarn --cwd dist/package install && yarn --cwd dist/package vsce package --out ../../",
"pretest": "yarn compile && yarn webpack",
"test": "sbt test && node ./out/tests/runTest.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say that either before or after node ./out/tests/runTest.js you want to run the svelte tests. So either,

"test": "sbt test && yarn test:svelte && node ./out/tests/runTest.js",

or

"test": "sbt test && node ./out/tests/runTest.js && yarn test:svelte",

I personally prefer the first option but either way is fine with me also. Once that is updated I think this is good to go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I initially did not have the tests being ran during the projects tests because there were a lot of compilation errors within the svelte tests. This is because of #878

Although, I found out that there are only compilation errors when mocha is trying to compile the files with the errors. The example tests that I have do not have any so I went ahead and implemented your changes to the test scripts.

@stricklandrbls
Copy link
Collaborator Author

@shanedell I added a new script & modified 2 existing scripts:

  • Added watch:svelte-tests - For having only the svelte tests watched during development.
  • Changed test:svelte to not have the -w option for watching.
  • Changed test to your first suggestion.

@stricklandrbls
Copy link
Collaborator Author

stricklandrbls commented Dec 13, 2023

@shanedell I added a new script & modified 2 existing scripts:

* Added `watch:svelte-tests` - For having only the svelte tests watched during development.

* Changed `test:svelte` to not have the `-w` option for watching.

* Changed `test` to your first suggestion.

Looks like the mocha side is still failing on the CI side due to the same compilation errors I mentioned before. I'm not entirely sure why though because running mocha -r ts-node/register ./src/svelte/tests/**/*.test.ts or yarn test:svelte does not throw those errors on my machine.

Even running the full yarn test does not have any errors.

@nlewis05
Copy link
Collaborator

My local build is passing
image

@scholarsmate
Copy link
Contributor

So far so good for me:

➜  daffodil-vscode-ctc-oss git:(setup-svelte-test-env) yarn test:svelte
yarn run v1.22.19
warning [email protected]: The engine "vscode" appears to be invalid.
$ mocha -r ts-node/register ./src/svelte/tests/**/*.test.ts


  Data Editor Stores ( Derived )
    regularSizedFile
      ✔ should return true on regular computed sized viewports
      ✔ should return false on non-regular computed sized viewports
    saveable
      ✔ should report boolean value derived from fileMetrics.changeCount

  Display Functions
    radixBytePad
      ✔ should return the appropriate text length per radix value given
    radixToString
      ✔ should return the correct radix index string from RadixValue


  5 passing (9ms)

✨  Done in 2.69s.

- Added yarn script to run data editor tests using Mocha.
- Added example function and Svelte store tests.

Closes apache#915
Copy link
Contributor

@shanedell shanedell left a comment

Choose a reason for hiding this comment

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

+1

@stricklandrbls stricklandrbls merged commit 4e45b16 into apache:main Jan 1, 2024
21 checks passed
@scholarsmate scholarsmate deleted the setup-svelte-test-env branch January 2, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues related to building of the code code quality Issues related to code quality configuration issues related to configuration data editor Issues related to the Data Editor capability enhancement New feature or request typescript
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Utilize Mocha Testsuite For Data Editor TS Objects
5 participants