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

Automated Testing #14

Merged
merged 6 commits into from
May 4, 2024
Merged

Automated Testing #14

merged 6 commits into from
May 4, 2024

Conversation

jonha1
Copy link
Contributor

@jonha1 jonha1 commented Mar 31, 2024

Reason:

Resolves Issue: Automated Testing #6

Changes:
Decided to use mocha for testing
Began working on unit tests for basic mathematical questions

Questions:

  • unsure how to automate it
  • unsure how to do regression tests for callouts

jonha1 added 2 commits March 26, 2024 17:39
- error: 'latLonToTileCoords is not a function' (find out why this error occurs)
- somehow all tests are failing
Copy link
Member

@steinbro steinbro left a comment

Choose a reason for hiding this comment

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

Thanks for getting started on this!

Regarding automation, this should just be a straightforward Github Action for testing JavaScript, as documented here: https://docs.github.com/en/[email protected]/actions/automating-builds-and-tests/building-and-testing-nodejs

For the first test suite, I'd stick to the kind of unit tests you have now -- testing callouts is going to be far more complicated. It would probably require a fair bit of refactoring to decouple the sound output, among many other things.

@@ -1,8 +1,12 @@
// Copyright (c) Daniel W. Steinbrook.
// with many thanks to ChatGPT

const turf = require('@turf/turf');

module.exports = { createBoundingBox , enumerateTilesInBoundingBox, getLocation, watchLocation, geoToXY};
Copy link
Member

Choose a reason for hiding this comment

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

This syntax might work in Node from the command line, but breaks in a browser. I'd think there should be a way to get Mocha to work while keeping ES6 module syntax like we have now. See: https://stackoverflow.com/questions/46487307/is-it-possible-to-use-es6-modules-in-mocha-tests

jonha1 and others added 4 commits April 18, 2024 23:43
@steinbro steinbro merged commit 59d6069 into soundscape-community:main May 4, 2024
2 checks passed
@steinbro
Copy link
Member

steinbro commented May 4, 2024

After much trial-and-error, I figured out how to get turf in the global namespace for tests without needing to add any imports to the source files (see tests/setup.js). I also added a Github Action to automate these (see .github/workflows/node.js.yml). Your tests will run on every future commit and pull request!

@steinbro steinbro mentioned this pull request May 4, 2024
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