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: re-order slow API tests #3869

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

test: re-order slow API tests #3869

wants to merge 4 commits into from

Conversation

erickzhao
Copy link
Member

@erickzhao erickzhao commented Mar 4, 2025

api.slow.spec.ts is the slowest test suite that we have, but is the set of integration tests that test our Forge commands end-to-end.

This PR does a few things to clean up the implementation of this suite:

  • Removes the beforeInitTest helper in favour of directly calling api.init in our tests. This makes the tests a bit easier to read.
  • Re-orders describe and it blocks to better represent the hierarchy of tests.
  • Avoids dynamically calling it in loops to create tests for Makers. Instead, leverage describe.each and it.each.
  • Removes the process.env.DISABLE_SQUIRREL_TEST environment variable from the MakerSquirrel implementation code, which we were using to disable the maker in tests.
 ✓  slow  packages/api/core/spec/slow/api.slow.spec.ts (66 tests) 418819ms
   ✓ with package manager = 'npm' > import > creates forge.config.js and can successfully package the application 15300ms
   ✓ with package manager = 'npm' > init > should successfully initialize a Forge project 12011ms
   ✓ with package manager = 'npm' > init > when directory already exists > should fail by default
   ✓ with package manager = 'npm' > init > when directory already exists > should successfully initialize if --force flag is on 11617ms
   ✓ with package manager = 'npm' > init > with skipGit > should not initialize a git repo if passed the skipGit option 11941ms
   ✓ with package manager = 'npm' > init > with custom templates > writes custom files correctly 13095ms
   ✓ with package manager = 'npm' > init > with custom templates > fails if template does not specify a Forge version
   ✓ with package manager = 'npm' > init > with custom templates > fails if template has a mismatched Forge version
   ✓ with package manager = 'npm' > init > with custom templates > fail if template does not exist
   ✓ with package manager = 'npm' > after init > package > throws an error when packagerConfig.all is set
   ✓ with package manager = 'npm' > after init > package > can package without errors 1626ms
   ✓ with package manager = 'npm' > after init > package > with custom outDir > should package to custom directory 1571ms
   ✓ with package manager = 'npm' > after init > package > with custom outDir > can make from custom directory 8327ms
   ✓ with package manager = 'npm' > after init > package > with prebuilt native module deps installed > should succeed 5342ms
   ✓ with package manager = 'npm' > after init > make > for target MakerDMG.js > can make without errors 7982ms
   ✓ with package manager = 'npm' > after init > make > for target MakerZIP.js > can make without errors 8461ms
   ✓ with package manager = 'npm' > after init > make > for target MakerSnap.js > fails
   ✓ with package manager = 'npm' > after init > make > throws an error when given an unrecognized platform
   ✓ with package manager = 'npm' > after init > make > throws an error when the specified maker doesn't support the current platform
   ✓ with package manager = 'npm' > after init > make > throws an error when the specified maker doesn't implement isSupportedOnCurrentPlatform()
   ✓ with package manager = 'npm' > after init > make > throws an error when no makers are configured for the given platform
   ✓ with package manager = 'npm' > after init > make > can make for the MAS platform successfully 12305ms
   ✓ with package manager = 'yarn' > import > creates forge.config.js and can successfully package the application 13890ms
   ✓ with package manager = 'yarn' > init > should successfully initialize a Forge project 12201ms
   ✓ with package manager = 'yarn' > init > when directory already exists > should fail by default
   ✓ with package manager = 'yarn' > init > when directory already exists > should successfully initialize if --force flag is on 12100ms
   ✓ with package manager = 'yarn' > init > with skipGit > should not initialize a git repo if passed the skipGit option 12313ms
   ✓ with package manager = 'yarn' > init > with custom templates > writes custom files correctly 13007ms
   ✓ with package manager = 'yarn' > init > with custom templates > fails if template does not specify a Forge version
   ✓ with package manager = 'yarn' > init > with custom templates > fails if template has a mismatched Forge version
   ✓ with package manager = 'yarn' > init > with custom templates > fail if template does not exist
   ✓ with package manager = 'yarn' > after init > package > throws an error when packagerConfig.all is set
   ✓ with package manager = 'yarn' > after init > package > can package without errors 1716ms
   ✓ with package manager = 'yarn' > after init > package > with custom outDir > should package to custom directory 1698ms
   ✓ with package manager = 'yarn' > after init > package > with custom outDir > can make from custom directory 8548ms
   ✓ with package manager = 'yarn' > after init > package > with prebuilt native module deps installed > should succeed 5601ms
   ✓ with package manager = 'yarn' > after init > make > for target MakerDMG.js > can make without errors 7900ms
   ✓ with package manager = 'yarn' > after init > make > for target MakerZIP.js > can make without errors 8643ms
   ✓ with package manager = 'yarn' > after init > make > for target MakerSnap.js > fails
   ✓ with package manager = 'yarn' > after init > make > throws an error when given an unrecognized platform
   ✓ with package manager = 'yarn' > after init > make > throws an error when the specified maker doesn't support the current platform
   ✓ with package manager = 'yarn' > after init > make > throws an error when the specified maker doesn't implement isSupportedOnCurrentPlatform()
   ✓ with package manager = 'yarn' > after init > make > throws an error when no makers are configured for the given platform
   ✓ with package manager = 'yarn' > after init > make > can make for the MAS platform successfully 11345ms
   ✓ with package manager = 'pnpm' > import > creates forge.config.js and can successfully package the application 14841ms
   ✓ with package manager = 'pnpm' > init > should successfully initialize a Forge project 16937ms
   ✓ with package manager = 'pnpm' > init > when directory already exists > should fail by default
   ✓ with package manager = 'pnpm' > init > when directory already exists > should successfully initialize if --force flag is on 19314ms
   ✓ with package manager = 'pnpm' > init > with skipGit > should not initialize a git repo if passed the skipGit option 12969ms
   ✓ with package manager = 'pnpm' > init > with custom templates > writes custom files correctly 13816ms
   ✓ with package manager = 'pnpm' > init > with custom templates > fails if template does not specify a Forge version
   ✓ with package manager = 'pnpm' > init > with custom templates > fails if template has a mismatched Forge version
   ✓ with package manager = 'pnpm' > init > with custom templates > fail if template does not exist
   ✓ with package manager = 'pnpm' > after init > package > throws an error when packagerConfig.all is set
   ✓ with package manager = 'pnpm' > after init > package > can package without errors 1747ms
   ✓ with package manager = 'pnpm' > after init > package > with custom outDir > should package to custom directory 1705ms
   ✓ with package manager = 'pnpm' > after init > package > with custom outDir > can make from custom directory 8611ms
   ✓ with package manager = 'pnpm' > after init > package > with prebuilt native module deps installed > should succeed 5991ms
   ✓ with package manager = 'pnpm' > after init > make > for target MakerDMG.js > can make without errors 7868ms
   ✓ with package manager = 'pnpm' > after init > make > for target MakerZIP.js > can make without errors 8510ms
   ✓ with package manager = 'pnpm' > after init > make > for target MakerSnap.js > fails
   ✓ with package manager = 'pnpm' > after init > make > throws an error when given an unrecognized platform
   ✓ with package manager = 'pnpm' > after init > make > throws an error when the specified maker doesn't support the current platform
   ✓ with package manager = 'pnpm' > after init > make > throws an error when the specified maker doesn't implement isSupportedOnCurrentPlatform()
   ✓ with package manager = 'pnpm' > after init > make > throws an error when no makers are configured for the given platform
   ✓ with package manager = 'pnpm' > after init > make > can make for the MAS platform successfully 10904ms

I also went ahead and moved a few more files around to better reflect the folder structure of the src/ folder.

@erickzhao erickzhao requested a review from a team as a code owner March 4, 2025 23:08
@erickzhao erickzhao marked this pull request as draft March 5, 2025 00:09
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.

1 participant