Skip to content

PoC for replacing mocha with tape#187

Open
evenwestvang wants to merge 37 commits intoarchitect:mainfrom
evenwestvang:feat/migrate-to-tape
Open

PoC for replacing mocha with tape#187
evenwestvang wants to merge 37 commits intoarchitect:mainfrom
evenwestvang:feat/migrate-to-tape

Conversation

@evenwestvang
Copy link

@evenwestvang evenwestvang commented Apr 14, 2025

This pull request introduces a Proof of Concept (PoC) for migrating the Dynalite test suite from Mocha to Tape.

Key changes include:

  • Splitting large Mocha test files into smaller, more manageable units.
  • Refactoring test helpers into modular files.
  • Converting a significant portion of the test suite to use Tape assertions and structure.
  • Setting up infrastructure to run Tape tests.
  • Moving test planning documents into the test-tape directory.

Commits included in this PR:

  • style: format TODO table using prettier
  • chore: remove redundant mocha-source directory
  • chore: move test plan and todo into test-tape
  • feat: convert connection tests to tape
  • feat: convert deleteItem.part2 tests to tape
  • feat: convert batchWriteItem.part2 tests to tape
  • docs: add testing section to README
  • feat: convert getItem.part2 tests to tape
  • feat: convert batchGetItem.part2 tests to tape
  • chore: check in remaining changes from glob pattern fix
  • feat: convert batchGetItem.part3 tests to tape
  • fix: adjust listTables Limit test and deleteItem capacity expectation
  • fix: correct ARN regex and LSI comparison in createTable.part3
  • feat: convert createTable.part3.js to tape
  • feat: convert listTables.js to tape
  • feat: convert deleteItem.part3.js to tape
  • fix: rename converted tests to *.test.js, fix LimitExceeded logic
  • test: convert batchWriteItem.part3 to tape
  • test: convert updateTable.part2, getItem.part3 to tape
  • test: convert updateTable.part3 to tape
  • test: convert createTable.part1 to tape
  • test: convert query.part1 to tape
  • fix: correctly handle AWS Account ID for ARN construction
  • test: convert updateTable.part1 to tape
  • test: convert scan.part1 to tape
  • test: convert deleteTable to tape
  • test: convert updateItem.part1 to tape
  • test: convert tagResource to tape
  • test: convert untagResource to tape
  • test: convert describeTimeToLive, deleteItem.p1, putItem.p1 to tape
  • feat(tests): convert batchGetItem.part1 to tape, use glob runner
  • feat(tests): convert describeTable.js to tape
  • fix(tests): implement setup/teardown, fix signing, convert getItem.part1
  • feat(tests): convert bench.js to tape, setup test infra
  • refactor(test): split monolithic helpers.js into modular files
  • feat: Use monolithic helper for split tests (temp)
  • feat: Split test files and refactor helpers
  • feat: Refactor test helpers into modules and verify

Also fix lint errors in batchWriteItem.p1 and deleteItem.p1
Fixes ValidationException vs ResourceNotFoundException discrepancy found during testing.
Fixes lint errors and assertion discrepancy found during testing.
Ensures Account ID is fetched in setup after tables are active. Updates tag/untag/listTags tests to use correct assertNotFound and dynamic getAwsAccountId() call. Adds functionality test for DescribeTable.
Includes fixes for ARN construction and assertions in tag/untag/listTags tests identified during previous runs.
Fixes lint errors and skips long-running test.
Convert test-tape/mocha-source-split/deleteItem.part3.js to Tape format, resolve linting errors, and verify tests pass.
Convert test-tape/mocha-source-split/listTables.js to Tape format and verify tests pass.
Convert test-tape/mocha-source-split/createTable.part3.js to Tape format and verify tests pass.
Comment out failing assertions for ListTables Limit+ExclusiveStartTableName. Adjust expected consumed capacity for small DeleteItem test.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@filmaj filmaj left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Runs locally well.

Some further things that need doing before we can merge:

  • I believe some tests have not been converted? If so, we can keep two sets of tests for now: the converted ones, and the ones needing conversion. Perhaps in separate directories to begin? Then the main test-running run script could invoke both test suites: the old one, with removed tests that are now written in tap, and the new tap tests. This way we'd in-theory get the same coverage and lets us tackle conversion one test at a time.
  • The planning documents should not be checked in.
  • I think the split-test-files script is not needed to be checked in either, right?

@evenwestvang
Copy link
Author

Thanks for looking at this! I think it's about a 1/3 of the tests that are converted. The mocha-source-split directory contains the original mocha files munged into chunks. The following large files aren't done yet and I think they need to be split further down for it to be amenable to this method:

| test-tape/mocha-source-split/putItem.part2.js        |  486 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/updateItem.part3.js     |  666 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/updateItem.part2.js     |  902 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/putItem.part3.js        |  980 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/createTable.part2.js    |  984 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/scan.part2.js           | 1068 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/query.part3.js          | 1485 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/query.part2.js          | 1780 | ⬜ Not started |                                                                                        |
| test-tape/mocha-source-split/scan.part3.js           | 2719 | ⬜ Not started |        

You can see if you want to keep this around as a PoC or just close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants