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

Test harness with jest #112

Merged
merged 12 commits into from
Dec 2, 2021
Merged

Conversation

awmartin
Copy link
Contributor

@awmartin awmartin commented Dec 1, 2021

Proposing to create a node-based test harness using the popular jest library. This could be used to enable a few workflows:

  • First, the typical value propositions around testing: ensuring changes don't break expected behavior, stability, etc.
  • Enabling some basic test-driven-development. For example, a reported bug can be confirmed with a failing test, then a branch created to fix it, code to make the test pass, then a PR to submit. This could include adding *.ifc files representing import challenges.
  • In the near future, running the test suite as part of commit flow or automated build pipelines.

This PR adds jest to the development dependencies and a new build action, test, to be executed with npm run test. Individual tests can be singled out with jest's features (regex, filename, etc.). In the future, we could add test:unit, test:e2e, etc. commands to single out test types.

It also proposes a fix to a bug uncovered with the included test.

* Adds jest.js as a testing library
* Run with `npm run test`
* Purposefully fails. To be resolved in next commit.
@awmartin
Copy link
Contributor Author

awmartin commented Dec 1, 2021

Going to convert to typescript as per @tomvandig's request.

* Adds ts-jest for easy management of Typescript test specs. https://github.com/kulshekhar/ts-jest
* Rewrite initial test in ts.
@awmartin awmartin mentioned this pull request Dec 1, 2021
@awmartin awmartin changed the title Proposal: Test harness with jest Test harness with jest Dec 1, 2021
@awmartin awmartin force-pushed the test-harness-with-jest branch 2 times, most recently from 92e9a9d to 7e6f685 Compare December 2, 2021 00:57
@awmartin
Copy link
Contributor Author

awmartin commented Dec 2, 2021

.gitignore excludes .ifc files, but examples/example.ifc seems to have already been included. Keeping test artifacts, particularly representative, small, IFC files, close to the functional tests might be convenient. One way to do this would be to reference test-ifc-files as a git submodule.

@awmartin awmartin marked this pull request as ready for review December 2, 2021 15:52
@awmartin
Copy link
Contributor Author

awmartin commented Dec 2, 2021

I think this is a good start to testing on the Typescript/Javascript side of the interface. I'd be curious to integrate this command npm run test (or npm test) with the CPP side as well. I see there's the start to those tests already.

The process uncovered a couple of bugs already, which I took the liberty to fix. :-)

One cavaet we should document once more tests are added is this requires a full build in the dist folder.

@tomvandig tomvandig merged commit 58d8d42 into ThatOpen:main Dec 2, 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