├── .all-contributorsrc ├── .codecov.yml ├── .editorconfig ├── .env.default ├── .gitattributes ├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ ├── FEATURE_REQUEST.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── SUPPORT.md ├── dependabot.yml ├── pipeline.config.js └── workflows │ ├── README.md │ ├── is-next-compat.yml │ ├── is-nextjestjs-swc-comat.yml │ ├── run-apollo-app-example.yml │ └── run-apollo-pages-example.yml ├── .gitignore ├── .husky ├── commit-msg ├── pre-commit └── pre-push ├── .ncurc.cjs ├── .prettierignore ├── .remarkrc.mjs ├── .spellcheckignore ├── .vscode ├── launch.example.json └── tasks.example.json ├── ARCHITECTURE.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINING.md ├── README.md ├── SECURITY.md ├── apollo_test_raw ├── apollo_test_raw_app_route ├── apollo_test_raw_app_test ├── babel.config.cjs ├── commitlint.config.mjs ├── conventional.config.cjs ├── docs ├── README.md ├── src │ ├── README.md │ ├── functions │ │ └── testApiHandler.md │ └── interfaces │ │ ├── NtarhInit.md │ │ ├── NtarhInitAppRouter.md │ │ └── NtarhInitPagesRouter.md └── test │ ├── setup │ └── README.md │ └── util │ ├── README.md │ ├── classes │ └── MockedExitError.md │ ├── functions │ ├── asMocked.md │ ├── describeRootFixture.md │ ├── dummyDirectoriesFixture.md │ ├── dummyFilesFixture.md │ ├── dummyNpmPackageFixture.md │ ├── ensurePackageHasBeenBuilt.md │ ├── getNextjsReactPeerDependencies.md │ ├── gitRepositoryFixture.md │ ├── isMockedExitError.md │ ├── isolatedImport.md │ ├── mockArgvFactory.md │ ├── mockEnvFactory.md │ ├── mockFixturesFactory.md │ ├── nodeImportAndRunTestFixture.md │ ├── npmCopyPackageFixture.md │ ├── npmLinkPackageFixture.md │ ├── protectedImportFactory.md │ ├── reconfigureJestGlobalsToSkipTestsInThisFileIfRequested.md │ ├── rootFixture.md │ ├── runTestFixture.md │ ├── webpackTestFixture.md │ ├── withMockedArgv.md │ ├── withMockedEnv.md │ ├── withMockedExit.md │ ├── withMockedFixtures.md │ ├── withMockedOutput.md │ └── withMocks.md │ ├── type-aliases │ ├── AsDefault.md │ ├── DescribeRootFixture.md │ ├── DescribeRootFixtureContext.md │ ├── DescribeRootFixtureOptions.md │ ├── DummyDirectoriesFixture.md │ ├── DummyDirectoriesFixtureContext.md │ ├── DummyDirectoriesFixtureOptions.md │ ├── DummyFilesFixture.md │ ├── DummyFilesFixtureContext.md │ ├── DummyFilesFixtureOptions.md │ ├── DummyNpmPackageFixture.md │ ├── DummyNpmPackageFixtureContext.md │ ├── DummyNpmPackageFixtureOptions.md │ ├── FixtureContext.md │ ├── FixtureFs.md │ ├── FixtureOptions.md │ ├── GenericFixtureContext.md │ ├── GenericMockFixture.md │ ├── GenericMockFixtureFunction.md │ ├── GenericMockFixtureFunctions.md │ ├── GitRepositoryFixture.md │ ├── GitRepositoryFixtureContext.md │ ├── GitRepositoryFixtureOptions.md │ ├── GlobalFixtureOptions.md │ ├── IsolatedImportOptions.md │ ├── MockFixture.md │ ├── MockedArgvOptions.md │ ├── MockedEnvOptions.md │ ├── MockedOutputOptions.md │ ├── MockedOutputSpies.md │ ├── NodeImportAndRunTestFixture.md │ ├── NodeImportAndRunTestFixtureContext.md │ ├── NodeImportAndRunTestFixtureOptions.md │ ├── NpmCopyPackageFixture.md │ ├── NpmCopyPackageFixtureContext.md │ ├── NpmCopyPackageFixtureOptions.md │ ├── NpmLinkPackageFixture.md │ ├── NpmLinkPackageFixtureContext.md │ ├── NpmLinkPackageFixtureOptions.md │ ├── RootFixture.md │ ├── RunTestFixture.md │ ├── RunTestFixtureContext.md │ ├── RunTestFixtureOptions.md │ ├── WebpackTestFixture.md │ ├── WebpackTestFixtureContext.md │ └── WebpackTestFixtureOptions.md │ └── variables │ ├── ExitErrorMessage.md │ ├── describeRootFixtureName.md │ ├── dummyDirectoriesFixtureName.md │ ├── dummyFilesFixtureName.md │ ├── dummyNpmPackageFixtureName.md │ ├── gitRepositoryFixtureName.md │ ├── globalDebugger.md │ ├── globalDebuggerNamespace.md │ ├── nodeImportAndRunTestFixtureName.md │ ├── npmCopyPackageFixtureName.md │ ├── npmLinkPackageFixtureName.md │ ├── rootFixtureName.md │ ├── runTestFixtureName.md │ └── webpackTestFixtureName.md ├── eslint.config.mjs ├── external-scripts └── is-next-compat.ts ├── gac.config.mjs ├── jest.config.mjs ├── lint-staged.config.mjs ├── logo.png ├── package-lock.json ├── package.json ├── prettier.config.mjs ├── release.config.cjs ├── src └── index.ts ├── test ├── e2e │ └── e2e.test.ts ├── integration │ ├── integration-client.test.ts │ └── integration-smoke-external.test.ts ├── setup.ts ├── type.test.ts ├── unit-external.test.ts ├── unit-index-imports.test.ts ├── unit-index.test.ts ├── unit-msw.test.ts └── util.ts ├── tsc.package.docs.json ├── tsc.package.lint.json ├── tsc.package.types.json ├── tsc.project.lint.json ├── tsconfig.json ├── tstyche.config.json └── very-first-version-of-ntarh.png /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: main 3 | coverage: 4 | range: '75...100' 5 | status: 6 | project: 7 | default: 8 | informational: true 9 | patch: 10 | default: 11 | informational: true 12 | # * Well-known flag syntax: package._ 13 | # * -id will be the WorkspacePackageId or "root" for RootPackages 14 | flag_management: 15 | # * These rules will apply to all non-specially-configured flags 16 | default_rules: 17 | carryforward: true 18 | statuses: 19 | - type: project 20 | target: auto 21 | - type: patch 22 | target: auto 23 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.env.default: -------------------------------------------------------------------------------- 1 | # shellcheck disable=all 2 | 3 | # MongoDB URI 4 | # 5 | # Required: if deploying 6 | # On-Sync: mirror 7 | # 8 | # MongoDB connect URI. Specify auth credentials if necessary. YOU MUST *NOT* 9 | # SPECIFY A DATABASE AT THE END! 10 | MONGODB_URI=mongodb://127.0.0.1:27017 11 | 12 | # Codecov test analysis token 13 | # 14 | # Required: if deploying 15 | # On-Sync: mirror 16 | # 17 | # The token used during CI/CD to analyze and upload build artifact code quality 18 | # data to Codecov. 19 | CODECOV_TOKEN= 20 | 21 | # GitHub deploy token 22 | # 23 | # Alias: GH_TOKEN 24 | # Required: if deploying 25 | # On-Sync: mirror 26 | # 27 | # The token used during CI/CD to interact with GitHub's API. 28 | GITHUB_TOKEN= 29 | 30 | # NPM deploy token 31 | # 32 | # Required: if deploying 33 | # On-Sync: mirror 34 | # 35 | # The token used during CD to login to NPM. Not referenced during non-CI/CD 36 | # (i.e. local, manual) deployments. 37 | NPM_TOKEN= 38 | 39 | # Git push author name 40 | # 41 | # Required: if deploying 42 | # On-Sync: mirror 43 | # 44 | # The token used during CD to set the author name of the git push. 45 | GIT_AUTHOR_NAME= 46 | 47 | # Git commit committer name 48 | # 49 | # Required: if deploying 50 | # On-Sync: mirror 51 | # 52 | # The token used during CD to set the name attached to any git commits. 53 | GIT_COMMITTER_NAME= 54 | 55 | # Git push author email 56 | # 57 | # Required: if deploying 58 | # On-Sync: mirror 59 | # 60 | # The token used during CD to set the author email of the git push. 61 | GIT_AUTHOR_EMAIL= 62 | 63 | # Git commit committer email 64 | # 65 | # Required: if deploying 66 | # On-Sync: mirror 67 | # 68 | # The token used during CD to set the email attached to any git commits. 69 | GIT_COMMITTER_EMAIL= 70 | 71 | # GPG private key passphrase 72 | # 73 | # Required: if deploying with CI/CD 74 | # On-Sync: mirror 75 | # 76 | # The passphrase used to unlock GPG_PRIVATE_KEY. Not referenced during non-CI/CD 77 | # (i.e. local, manual) deployments. 78 | GPG_PASSPHRASE= 79 | 80 | # GPG private key 81 | # 82 | # Required: if deploying with CI/CD 83 | # On-Sync: mirror 84 | # 85 | # The GPG key used to sign all git commits and releases. Not referenced during 86 | # non-CI/CD (i.e. local, manual) deployments. 87 | GPG_PRIVATE_KEY= 88 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # See https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/about-code-owners 2 | 3 | * @Xunnamius 4 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and 9 | expression, level of experience, education, socioeconomic status, nationality, 10 | personal appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | - Using welcoming and inclusive language. 18 | - Being respectful of differing viewpoints and experiences. 19 | - Gracefully accepting constructive criticism. 20 | - Focusing on what is best for the community. 21 | - Showing empathy towards other community members. 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | - Racism or sexism in any shape or form. 26 | - The use of sexualized language or imagery and unwelcome sexual attention or 27 | advances. 28 | - Trolling, insulting/derogatory comments, and personal or political attacks. 29 | - Public or private harassment. 30 | - Publishing others' private information, such as a physical or electronic 31 | address, without explicit permission. 32 | - Other conduct which could reasonably be considered inappropriate in a 33 | professional setting. 34 | 35 | ## Our Responsibilities 36 | 37 | Project maintainers are responsible for clarifying the standards of acceptable 38 | behavior and are expected to take appropriate and fair corrective action in 39 | response to any instances of unacceptable behavior. 40 | 41 | Project maintainers have the right and responsibility to remove, edit, or reject 42 | comments, commits, code, wiki edits, issues, and other contributions that are 43 | not aligned to this Code of Conduct, or to ban temporarily or permanently any 44 | contributor for other behaviors that they deem inappropriate, threatening, 45 | offensive, or harmful. 46 | 47 | ## Scope 48 | 49 | This Code of Conduct applies both within project spaces and in public spaces 50 | when an individual is representing the project or its community. Examples of 51 | representing a project or community include using an official project e-mail 52 | address, posting via an official social media account, or acting as an appointed 53 | representative at an online or offline event. Representation of a project may be 54 | further defined and clarified by project maintainers. 55 | 56 | ## Enforcement 57 | 58 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 59 | reported by contacting the project team at 60 | [Xunnamius@users.noreply.github.com][1]. All complaints will be reviewed and 61 | investigated and will result in a response that is deemed necessary and 62 | appropriate to the circumstances. The project team is obligated to maintain 63 | confidentiality with regard to the reporter of an incident. Further details of 64 | specific enforcement policies may be posted separately. 65 | 66 | Project maintainers who do not follow or enforce the Code of Conduct in good 67 | faith may face temporary or permanent repercussions as determined by other 68 | members of the project's leadership. 69 | 70 | ## Attribution 71 | 72 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 73 | version 1.4, available at 74 | [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html][2] 75 | 76 | For answers to common questions about this code of conduct, see 77 | [https://www.contributor-covenant.org/faq][3] 78 | 79 | [homepage]: https://www.contributor-covenant.org 80 | [1]: mailto:Xunnamius@users.noreply.github.com 81 | [2]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 82 | [3]: https://www.contributor-covenant.org/faq 83 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [Xunnamius] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🤯 Bug report 3 | about: Alert us about an issue 4 | labels: bug 5 | --- 6 | 7 | 8 | 9 |
The problem 10 | 11 | 16 | 17 |
18 | 19 |
Reproduction steps 20 | 21 | 34 | 35 |
36 | 37 | 46 | 47 | 56 | 57 | 78 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🤩 Feature request 3 | about: Tell us about your awesome idea 4 | labels: enhancement 5 | --- 6 | 7 | 8 | 9 | 17 | 18 | 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Security Channel 4 | url: 'mailto:security@ergodark.com?subject=SECURITY%20INCIDENT%3A%20%28five%20word%20summary%29' 5 | about: Report security-related issues here! 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | --- 8 | 9 | 10 | 11 | - [ ] I have read **[CONTRIBUTING.md][1]**. 12 | - [ ] This PR is not security related (see [SECURITY.md][2]). 13 | 14 | [1]: /CONTRIBUTING.md 15 | [2]: /SECURITY.md 16 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support [![Average issue resolution time][badge-issue-resolution]][link-issue-resolution] [![Issue open percentage][badge-issue-percentage]][open-issues] 2 | 3 | Need help? Want to help this project? See below! 4 | 5 | ## Reporting an Issue 6 | 7 | Before you begin, please [search open and past issues][open-issues] to see if 8 | your issue or feature request is already being talked about. 9 | 10 | If you find your issue already exists, make sure to [bump the issue by adding a 11 | reaction][github-blog]. **If you're serious about wanting an issue to get 12 | attention, use a reaction in place of a "+1" or other similar comment.** 13 | 14 | If you cannot find an existing issue that describes your bug or feature, then 15 | you're clear to create your issue using the guidelines below. 16 | 17 | ### Standard Reactions 18 | 19 | Analysis of issue popularity (by tooling or otherwise) relies on the following 20 | reaction emojis being present on issues, PRs, and replies: 21 | 22 | `:+1:` 👍🏿👍🏾👍🏽👍🏼👍🏻👍 — up vote (AKA: _approve_, _like_, _+1_) 23 | 24 | `:-1:` 👎🏿👎🏾👎🏽👎🏼👎🏻👎 — down vote (AKA: _disapprove_, _dislike_, _-1_) 25 | 26 | ### Bug Reports and Feature Requests 27 | 28 | For the timeliest resolution to bug reports specifically, please make a good 29 | faith effort to [follow the template][choose-new-issue]. The more quality 30 | information you can provide, the quicker a fix will be found. Additionally: 31 | 32 | - Ensure you file one issue per problem or feature request. 33 | - Do not enumerate multiple bugs or feature requests in the same issue. 34 | - Do not add your issue as a comment to an existing issue unless you're 35 | experiencing identical behavior or behavior that stems from the exact same 36 | problem. 37 | 38 | That's it! You are now ready to [submit a new issue][choose-new-issue]! Thank 39 | you for contribution 🎉, your efforts are greatly appreciated! 🙌🏿 40 | 41 | #### Closure Policy 42 | 43 | - Issues that do not follow the appropriate template or contain necessary 44 | information may be closed immediately and the poster directed to these 45 | guidelines. 46 | - Issues that go for an extended period without activity are subject to closure. 47 | 48 | [badge-issue-percentage]: 49 | https://isitmaintained.com/badge/open/Xunnamius/next-test-api-route-handler.svg 50 | 'Open issues as a percentage of all issues' 51 | [badge-issue-resolution]: 52 | https://isitmaintained.com/badge/resolution/Xunnamius/next-test-api-route-handler.svg 53 | 'Average time to resolve an issue' 54 | [choose-new-issue]: 55 | https://github.com/Xunnamius/next-test-api-route-handler/issues/new/choose 56 | [github-blog]: 57 | https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments 58 | [link-issue-resolution]: 59 | https://isitmaintained.com/project/Xunnamius/next-test-api-route-handler 60 | [open-issues]: 61 | https://github.com/Xunnamius/next-test-api-route-handler/issues?q= 62 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: daily 7 | commit-message: 8 | prefix: 'chore' 9 | prefix-development: 'chore' 10 | include: 'scope' 11 | 12 | - package-ecosystem: npm 13 | directory: / 14 | schedule: 15 | interval: daily 16 | commit-message: 17 | prefix: 'build' 18 | prefix-development: 'chore' 19 | include: 'scope' 20 | -------------------------------------------------------------------------------- /.github/pipeline.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This object is used to configure the GitHub Actions that comprise the 3 | * build-test-deploy pipeline. Each property is optional. 4 | */ 5 | module.exports = { 6 | // * The name and email used to author commits and interact with GitHub. 7 | // ! This should correspond to the identity of the GH_TOKEN secret. 8 | // committer: { 9 | // name: 'xunn-bot', 10 | // email: 'bot@xunn.io' 11 | // }, 12 | // 13 | // * Selectively enable debugger verbose output in the pipeline. 14 | // ? To enable debugging across all source in this repo (excluding 15 | // ? node_modules) without having to type the package name, use a boolean: 16 | // debugString: true, // false is treated the same as null/commented out 17 | // ? Or you can type out a custom debug namespace string instead, e.g.: 18 | // debugString: '@your-namespace/some-package:*', 19 | // ? This key can only appear in local pipeline config and not global. 20 | // ? See also: https://www.npmjs.com/package/debug#wildcards 21 | // ? For even more debugging tools, see: https://bit.ly/2R6NAdZ 22 | // 23 | // * The semver version of node to install and setup before each job. 24 | // nodeCurrentVersion: '18.x', 25 | // 26 | // * Node semver versions to run unit and integration tests against. 27 | // nodeTestVersions: ['14.x', '16.x'], 28 | // 29 | // * Webpack semver versions to run unit and integration tests against. 30 | // webpackTestVersions: ['5.x'], 31 | // 32 | // * Regular expressions for skipping CI/CD. To skip CL, use git with the 33 | // * `--no-verify` option. 34 | // ciSkipRegex: /\[skip ci\]|\[ci skip\]/i, 35 | // cdSkipRegex: /\[skip cd\]|\[cd skip\]/i, 36 | // 37 | // * Should auto-merge be retried on failure even when the PR appears 38 | // * unmergeable? If `true`, uses exponential back-off internally. 39 | // ! WARNING: leaving this as `true` might waste Actions minutes and $$$ in 40 | // ! private repositories. Watch your usage numbers! 41 | // canRetryAutomerge: true, 42 | // 43 | // * Npm audit will fail upon encountering problems of at least the specified 44 | // * severity. 45 | // npmAuditFailLevel: 'high', 46 | // 47 | // * Attempt to upload project coverage data to codecov if `true`. 48 | // canUploadCoverage: true, 49 | // 50 | // * The maximum amount of time in seconds any "retry"-type operation can 51 | // * continue retrying. This includes all exponential backoff steps. 52 | // ! A 5 minute limit is hardcoded into pipeline workflows, so values above 53 | // ! ~250 might lead to undesirable VM hard stops. 54 | // retryCeilingSeconds: 180, 55 | // 56 | // * How many days GitHub should keep uploaded artifacts around. 57 | // ! 90 days is GitHub's default, but this should be lowered to 1 day for 58 | // ! private repos where artifact storage costs $$$. 59 | // artifactRetentionDays: 90 60 | }; 61 | -------------------------------------------------------------------------------- /.github/workflows/README.md: -------------------------------------------------------------------------------- 1 | Details on pipeline design and operation can be found [here][1]. 2 | 3 | [1]: https://github.com/Xunnamius/symbiote/wiki 4 | -------------------------------------------------------------------------------- /.github/workflows/is-next-compat.yml: -------------------------------------------------------------------------------- 1 | name: is-next-compat 2 | 3 | # ! If you want to use this workflow, the following secrets must be defined: 4 | # ! - MONGODB_URI 5 | # ! - GH_TOKEN 6 | 7 | on: 8 | workflow_dispatch: # * Treated like a scheduled run 9 | schedule: 10 | - cron: '0 */6 * * *' 11 | 12 | env: 13 | # * Selectively enable debugger verbose output in the pipeline 14 | # ? See also: https://www.npmjs.com/package/debug#wildcards 15 | # DEBUG: 'next-test-api-route-handler:*' 16 | NODE_CURRENT_VERSION: '>=24' 17 | NODE_OLDER_VERSIONS: '"20.x", "22.x"' 18 | 19 | jobs: 20 | metadata: 21 | name: 'gather-metadata' 22 | runs-on: ubuntu-latest 23 | timeout-minutes: 10 24 | outputs: 25 | node-matrix: ${{ steps.set-matrix.outputs.node-matrix }} 26 | steps: 27 | - name: Report mode statuses 28 | run: | 29 | if [ -n "$DEBUG" ]; then 30 | echo "IS-NEXT-COMPAT IS RUNNING IN DEBUG MODE ($DEBUG)" 31 | else 32 | echo '(is-next-compat is not running in debug mode)' 33 | fi 34 | 35 | - name: Gather metadata 36 | id: set-matrix 37 | run: | 38 | echo "node-matrix={\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" >> $GITHUB_OUTPUT 39 | ! [ -z "$DEBUG" ] && echo "set-output name=node-matrix::{\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" || true 40 | 41 | check-compat: 42 | runs-on: ubuntu-latest 43 | needs: metadata 44 | strategy: 45 | fail-fast: false 46 | matrix: ${{ fromJson(needs.metadata.outputs.node-matrix) }} 47 | steps: 48 | # GitHub Actions artifacts cannot handle filenames with certain characters 49 | - name: Reify metadata 50 | id: reified-metadata 51 | env: 52 | NODE_VERSION: ${{ matrix.node }} 53 | run: > 54 | node -p 55 | '`node-version-sanitized=${process.env.NODE_VERSION.replaceAll( 56 | /[":<>|*?\\\/=,\s'"'"']/g,"-")}`' >> "$GITHUB_OUTPUT" 57 | 58 | - name: Checkout 59 | uses: actions/checkout@v4 60 | with: 61 | persist-credentials: false 62 | 63 | # See: https://github.com/actions/setup-node/issues/214#issuecomment-810829250 64 | - name: Reconfigure git to use HTTP authentication 65 | run: > 66 | git config --global url."https://github.com/".insteadOf 67 | ssh://git@github.com/ 68 | 69 | - name: Use node ${{ matrix.node }} 70 | uses: actions/setup-node@v4.3.0 71 | with: 72 | node-version: ${{ matrix.node }} 73 | 74 | - name: Cache npm 75 | uses: actions/cache@v4 76 | id: cache-npm 77 | with: 78 | key: 79 | npm-node-${{ matrix.node }}-${{ runner.os }}-${{ 80 | hashFiles('**/package-lock.json') }} 81 | path: ~/.npm 82 | restore-keys: npm-node-${{ matrix.node }}-${{ runner.os }}- 83 | 84 | # Turns out tee eats exit codes... ... sigh 85 | # Also, we use npm install over npm ci for more accurate test results 86 | - name: Install CI dependencies 87 | run: | 88 | mkfifo '#pipe.ignore' 89 | tee --append /tmp/output.txt < '#pipe.ignore' & 90 | npm install --force > '#pipe.ignore' 2>&1 91 | rm '#pipe.ignore' 92 | 93 | - name: Build distributables 94 | run: | 95 | mkfifo '#pipe.ignore' 96 | tee --append /tmp/output.txt < '#pipe.ignore' & 97 | npm run build:dist > '#pipe.ignore' 2>&1 98 | rm '#pipe.ignore' 99 | 100 | - name: Build externals 101 | run: npm run build:externals 102 | 103 | - name: Run is-next-compat 104 | env: 105 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 106 | MONGODB_URI: ${{ secrets.MONGODB_URI }} 107 | NODE_TARGET_VERSION: ${{ env.NODE_CURRENT_VERSION }} 108 | run: | 109 | mkfifo '#pipe.ignore' 110 | tee --append /tmp/output.txt < '#pipe.ignore' & 111 | node --no-warnings external-scripts/bin/is-next-compat.js > '#pipe.ignore' 2>&1 112 | rm '#pipe.ignore' 113 | 114 | - name: Upload output artifact 115 | if: always() 116 | uses: actions/upload-artifact@v4 117 | with: 118 | name: 119 | output-node-${{ 120 | steps.reified-metadata.outputs.node-version-sanitized }}-${{ 121 | github.sha }} 122 | path: /tmp/output.txt 123 | if-no-files-found: error 124 | retention-days: 1 125 | -------------------------------------------------------------------------------- /.github/workflows/is-nextjestjs-swc-comat.yml: -------------------------------------------------------------------------------- 1 | name: is-nextjestjs-swc-comat 2 | 3 | on: 4 | workflow_dispatch: # * Treated like a scheduled run 5 | schedule: 6 | - cron: '15 */6 * * *' 7 | 8 | env: 9 | # * Selectively enable debugger verbose output in the pipeline 10 | # ? See also: https://www.npmjs.com/package/debug#wildcards 11 | # DEBUG: 'next-test-api-route-handler:*' 12 | NODE_CURRENT_VERSION: '>=24' 13 | NODE_OLDER_VERSIONS: '"20.x", "22.x"' 14 | 15 | jobs: 16 | metadata: 17 | name: 'gather-metadata' 18 | runs-on: ubuntu-latest 19 | timeout-minutes: 10 20 | outputs: 21 | node-matrix: ${{ steps.set-matrix.outputs.node-matrix }} 22 | steps: 23 | - name: Report mode statuses 24 | run: | 25 | if [ -n "$DEBUG" ]; then 26 | echo "IS-NEXTJESTJS-SWC-COMAT IS RUNNING IN DEBUG MODE ($DEBUG)" 27 | else 28 | echo '(is-nextjestjs-swc-comat is not running in debug mode)' 29 | fi 30 | 31 | - name: Gather metadata 32 | id: set-matrix 33 | run: | 34 | echo "node-matrix={\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" >> $GITHUB_OUTPUT 35 | ! [ -z "$DEBUG" ] && echo "set-output name=node-matrix::{\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" || true 36 | 37 | check-compat: 38 | runs-on: ubuntu-latest 39 | needs: metadata 40 | timeout-minutes: 10 41 | strategy: 42 | fail-fast: false 43 | matrix: ${{ fromJson(needs.metadata.outputs.node-matrix) }} 44 | steps: 45 | # GitHub Actions artifacts cannot handle filenames with certain characters 46 | - name: Reify metadata 47 | id: reified-metadata 48 | env: 49 | NODE_VERSION: ${{ matrix.node }} 50 | run: > 51 | node -p 52 | '`node-version-sanitized=${process.env.NODE_VERSION.replaceAll( 53 | /[":<>|*?\\\/=,\s'"'"']/g,"-")}`' >> "$GITHUB_OUTPUT" 54 | 55 | - name: Checkout 56 | uses: actions/checkout@v4 57 | with: 58 | persist-credentials: false 59 | 60 | # See: https://github.com/actions/setup-node/issues/214#issuecomment-810829250 61 | - name: Reconfigure git to use HTTP authentication 62 | run: > 63 | git config --global url."https://github.com/".insteadOf 64 | ssh://git@github.com/ 65 | 66 | - name: Use node ${{ matrix.node }} 67 | uses: actions/setup-node@v4.3.0 68 | 69 | - name: Cache npm 70 | uses: actions/cache@v4 71 | id: cache-npm 72 | with: 73 | key: 74 | npm-node-${{ matrix.node }}-${{ runner.os }}-${{ 75 | hashFiles('**/package-lock.json') }} 76 | path: ~/.npm 77 | restore-keys: npm-node-${{ matrix.node }}-${{ runner.os }}- 78 | 79 | # Turns out tee eats exit codes... ... sigh 80 | # Also, we use npm install over npm ci for more accurate test results 81 | - name: Install CI dependencies 82 | run: | 83 | mkfifo '#pipe.ignore' 84 | tee --append /tmp/output.txt < '#pipe.ignore' & 85 | npm install --force > '#pipe.ignore' 2>&1 86 | rm '#pipe.ignore' 87 | 88 | - name: Build externals (we're only interested in util.js) 89 | run: npm run build:externals 90 | 91 | # We need to install Next.js's peer dependencies by hand because it is 92 | # possible that Vercel devs publish broken package.json peerDependencies 93 | # 94 | # Also, note that, when piping stuff, npm install seems to break the pipe 95 | # for any processes that come after it. Not sure why, but can be fixed by 96 | # rm-ing and re-mkfifo-ing the pipe. 97 | - name: Run davidmytton's example repo tests 98 | # https://github.com/Xunnamius/next-test-api-route-handler/discussions/983# 99 | run: | 100 | previous_cwd=$(pwd) 101 | mkdir -p /tmp/ntarh-test 102 | git clone https://github.com/Xunnamius/ntarh-nextjestjs-swc-compat-test /tmp/ntarh-test 103 | cd /tmp/ntarh-test 104 | 105 | mkfifo '#pipe.ignore' 106 | tee --append /tmp/output.txt < '#pipe.ignore' & 107 | 108 | npm install --force > '#pipe.ignore' 2>&1 109 | 110 | extra_installs=$(node -e '(async () => console.log((await require("'"$previous_cwd"'/external-scripts/bin/util.js").getNextjsReactPeerDependencies("next@latest")).join(" ")))()') 111 | 112 | rm '#pipe.ignore' 113 | mkfifo '#pipe.ignore' 114 | tee --append /tmp/output.txt < '#pipe.ignore' & 115 | 116 | if [[ -n "$extra_installs" ]]; then 117 | echo installing extra_installs: 118 | npm install --force --no-save $(echo $extra_installs) > '#pipe.ignore' 2>&1 119 | fi 120 | 121 | echo listing deps: 122 | npm list next 123 | npm list next-test-api-route-handler 124 | npm list react 125 | npm list react-dom 126 | 127 | 128 | echo running jest: 129 | npx jest 130 | 131 | echo done 132 | rm '#pipe.ignore' 133 | 134 | - name: Upload output artifact 135 | if: always() 136 | uses: actions/upload-artifact@v4 137 | with: 138 | name: 139 | output-node-${{ 140 | steps.reified-metadata.outputs.node-version-sanitized }}-${{ 141 | github.sha }} 142 | path: /tmp/output.txt 143 | if-no-files-found: error 144 | retention-days: 1 145 | -------------------------------------------------------------------------------- /.github/workflows/run-apollo-app-example.yml: -------------------------------------------------------------------------------- 1 | name: run-apollo-app-example 2 | 3 | on: 4 | workflow_dispatch: # * Treated like a scheduled run 5 | inputs: 6 | dist-tag: 7 | type: string 8 | description: NTARH version to test 9 | required: true 10 | default: 'latest' 11 | schedule: 12 | - cron: '30 */6 * * *' 13 | 14 | env: 15 | # * Selectively enable debugger verbose output in the pipeline 16 | # ? See also: https://www.npmjs.com/package/debug#wildcards 17 | # DEBUG: 'next-test-api-route-handler:*' 18 | NODE_CURRENT_VERSION: '>=24' 19 | NODE_OLDER_VERSIONS: '"20.x", "22.x"' 20 | 21 | jobs: 22 | metadata: 23 | name: 'gather-metadata' 24 | runs-on: ubuntu-latest 25 | timeout-minutes: 10 26 | outputs: 27 | node-matrix: ${{ steps.set-matrix.outputs.node-matrix }} 28 | steps: 29 | - name: Report mode statuses 30 | run: | 31 | if [ -n "$DEBUG" ]; then 32 | echo "RUN-APOLLO-APP-EXAMPLE IS RUNNING IN DEBUG MODE ($DEBUG)" 33 | else 34 | echo '(run-apollo-app-example is not running in debug mode)' 35 | fi 36 | 37 | - name: Gather metadata 38 | id: set-matrix 39 | run: | 40 | echo "node-matrix={\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" >> $GITHUB_OUTPUT 41 | ! [ -z "$DEBUG" ] && echo "set-output name=node-matrix::{\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" || true 42 | 43 | check-compat: 44 | runs-on: ubuntu-latest 45 | needs: metadata 46 | timeout-minutes: 10 47 | strategy: 48 | fail-fast: false 49 | matrix: ${{ fromJson(needs.metadata.outputs.node-matrix) }} 50 | steps: 51 | # GitHub Actions artifacts cannot handle filenames with certain characters 52 | - name: Reify metadata 53 | id: reified-metadata 54 | env: 55 | NODE_VERSION: ${{ matrix.node }} 56 | run: > 57 | node -p 58 | '`node-version-sanitized=${process.env.NODE_VERSION.replaceAll( 59 | /[":<>|*?\\\/=,\s'"'"']/g,"-")}`' >> "$GITHUB_OUTPUT" 60 | 61 | - name: Checkout 62 | uses: actions/checkout@v4 63 | with: 64 | persist-credentials: false 65 | 66 | # See: https://github.com/actions/setup-node/issues/214#issuecomment-810829250 67 | - name: Reconfigure git to use HTTP authentication 68 | run: > 69 | git config --global url."https://github.com/".insteadOf 70 | ssh://git@github.com/ 71 | 72 | - name: Use node ${{ matrix.node }} 73 | uses: actions/setup-node@v4.3.0 74 | 75 | - name: Cache npm 76 | uses: actions/cache@v4 77 | id: cache-npm 78 | with: 79 | key: 80 | npm-node-${{ matrix.node }}-${{ runner.os }}-${{ 81 | hashFiles('**/package-lock.json') }} 82 | path: ~/.npm 83 | restore-keys: npm-node-${{ matrix.node }}-${{ runner.os }}- 84 | 85 | # Turns out tee eats exit codes... ... sigh 86 | # Also, we use npm install over npm ci for more accurate test results 87 | - name: Install CI dependencies 88 | run: | 89 | mkfifo '#pipe.ignore' 90 | tee --append /tmp/output.txt < '#pipe.ignore' & 91 | npm install --force > '#pipe.ignore' 2>&1 92 | rm '#pipe.ignore' 93 | 94 | - name: Build externals (we're only interested in util.js) 95 | run: npm run build:externals 96 | 97 | # We need to install Next.js's peer dependencies by hand because it is 98 | # possible that Vercel devs publish broken package.json peerDependencies 99 | # 100 | # Also, note that, when piping stuff, npm install seems to break the pipe 101 | # for any processes that come after it. Not sure why, but can be fixed by 102 | # rm-ing and re-mkfifo-ing the pipe. 103 | - name: Run apollo terminal example 104 | # https://bit.ly/38702j0 105 | run: | 106 | previous_cwd=$(pwd) 107 | mkdir -p /tmp/ntarh-test/test 108 | cd /tmp/ntarh-test 109 | 110 | mkfifo '#pipe.ignore' 111 | tee --append /tmp/output.txt < '#pipe.ignore' & 112 | 113 | extra_installs=$(node -e '(async () => console.log((await require("'"$previous_cwd"'/external-scripts/bin/util.js").getNextjsReactPeerDependencies("next@latest")).join(" ")))()') 114 | 115 | npm install --force next @apollo/server @as-integrations/next graphql-tag next-test-api-route-handler jest babel-jest @babel/core @babel/preset-env $(echo $extra_installs) > '#pipe.ignore' 2>&1 116 | 117 | echo 'module.exports={presets:["@babel/preset-env"]};' > babel.config.js 118 | mkdir -p app/api/graphql 119 | 120 | curl -o app/api/graphql/route.js https://raw.githubusercontent.com/Xunnamius/next-test-api-route-handler/main/apollo_test_raw_app_route 121 | 122 | curl -o test/integration.test.js https://raw.githubusercontent.com/Xunnamius/next-test-api-route-handler/main/apollo_test_raw_app_test 123 | 124 | npx jest 125 | 126 | rm '#pipe.ignore' 127 | -------------------------------------------------------------------------------- /.github/workflows/run-apollo-pages-example.yml: -------------------------------------------------------------------------------- 1 | name: run-apollo-pages-example 2 | 3 | on: 4 | workflow_dispatch: # * Treated like a scheduled run 5 | inputs: 6 | dist-tag: 7 | type: string 8 | description: NTARH version to test 9 | required: true 10 | default: 'latest' 11 | schedule: 12 | - cron: '0 */6 * * *' 13 | 14 | env: 15 | # * Selectively enable debugger verbose output in the pipeline 16 | # ? See also: https://www.npmjs.com/package/debug#wildcards 17 | # DEBUG: 'next-test-api-route-handler:*' 18 | NODE_CURRENT_VERSION: '>=24' 19 | NODE_OLDER_VERSIONS: '"20.x", "22.x"' 20 | 21 | jobs: 22 | metadata: 23 | name: 'gather-metadata' 24 | runs-on: ubuntu-latest 25 | timeout-minutes: 10 26 | outputs: 27 | node-matrix: ${{ steps.set-matrix.outputs.node-matrix }} 28 | steps: 29 | - name: Report mode statuses 30 | run: | 31 | if [ -n "$DEBUG" ]; then 32 | echo "RUN-APOLLO-PAGES-EXAMPLE IS RUNNING IN DEBUG MODE ($DEBUG)" 33 | else 34 | echo '(run-apollo-pages-example is not running in debug mode)' 35 | fi 36 | 37 | - name: Gather metadata 38 | id: set-matrix 39 | run: | 40 | echo "node-matrix={\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" >> $GITHUB_OUTPUT 41 | ! [ -z "$DEBUG" ] && echo "set-output name=node-matrix::{\"node\":[$NODE_OLDER_VERSIONS, \"$NODE_CURRENT_VERSION\"]}" || true 42 | 43 | check-compat: 44 | runs-on: ubuntu-latest 45 | needs: metadata 46 | timeout-minutes: 10 47 | strategy: 48 | fail-fast: false 49 | matrix: ${{ fromJson(needs.metadata.outputs.node-matrix) }} 50 | steps: 51 | - name: Run apollo terminal example 52 | # https://bit.ly/38702j0 53 | run: | 54 | git clone --depth=1 https://github.com/vercel/next.js /tmp/ntarh-test 55 | cd /tmp/ntarh-test/examples/api-routes-apollo-server-and-client 56 | npm install --force 57 | npm install --force next-test-api-route-handler jest babel-jest @babel/core @babel/preset-env 58 | # You could test with an older version of Next.js if you want, e.g.: 59 | # npm install --force next@9.0.6 60 | # Or even older: 61 | # npm install --force next@9.0.0 next-server 62 | echo 'module.exports={presets:["@babel/preset-env"]};' > babel.config.js 63 | mkdir test 64 | curl -o test/integration.test.js https://raw.githubusercontent.com/Xunnamius/next-test-api-route-handler/main/apollo_test_raw 65 | npx jest 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ! Note that any pattern with a / in the beginning OR MIDDLE (but not end) will 2 | # ! be considered relative to this file ONLY. Matching subdirs will NOT match! 3 | # ! Otherwise, patterns will match entities in any directory or subdirectory. 4 | # ! Prepend ** (or **/) if advanced subdir matching of complex paths is desired. 5 | # ! See https://git-scm.com/docs/gitignore#_pattern_format 6 | 7 | # Ignore temporary files in any subdir by giving them a special name 8 | *.ignore 9 | *.ignore.* 10 | ignore.* 11 | tmp 12 | 13 | # Ignore sensitive files in any subdir 14 | .env 15 | .npmrc 16 | *.local 17 | 18 | # Ignore transpiled source in any subdir (used for advanced debugging) 19 | .transpiled 20 | 21 | # Ignore packaged files that probably shouldn't be committed 22 | *.tgz 23 | *.tar.gz 24 | 25 | # Ignore relevant build artifacts in any subdir (with exceptions) 26 | *.tsbuildinfo 27 | # ? Preceding asterisks "**/" are needed to match any build subdir in monorepos 28 | # ? and proceeding asterisks "/**" allow subsequent negations to be interpreted 29 | # ? properly. See: https://git-scm.com/docs/gitignore#_pattern_format 30 | **/build/** 31 | # ? This and other negations must end in "/**" to be interpreted properly. 32 | !**/src/**/build/** 33 | # ? This and other negations must end in "/**" to be interpreted properly. 34 | !**/docs/**/build/** 35 | dist 36 | coverage 37 | lib-cov 38 | .nyc_output 39 | .grunt 40 | bower_components 41 | .lock-wscript 42 | build/Release 43 | .vercel 44 | .next 45 | next-env.d.ts 46 | 47 | # Ignore cloned GitHub wiki (do not regard it as a so-called "submodule") 48 | # ? Note that this complex path is relative to this file 49 | /.wiki 50 | 51 | # Ignore local vscode configuration 52 | # ? Note that this complex path is relative to this file 53 | /.vscode/** 54 | # ? Note that this complex path is relative to this file 55 | !/.vscode/*.example.json 56 | 57 | # Ignore relevant NPM and JSPM artifacts in any subdir 58 | .npm 59 | node_modules 60 | jspm_packages 61 | 62 | # Ignore logs in any subdir 63 | logs 64 | *.log 65 | npm-debug.log* 66 | yarn-debug.log* 67 | yarn-error.log* 68 | 69 | # Ignore random nothingness in any subdir 70 | .eslintcache 71 | .node_repl_history 72 | .yarn-integrity 73 | *.DS_Store 74 | .AppleDouble 75 | .LSOverride 76 | *~ 77 | .fuse_hidden* 78 | .directory 79 | .Trash-* 80 | .nfs* 81 | .DocumentRevisions-V100 82 | .fseventsd 83 | .Spotlight-V100 84 | .TemporaryItems 85 | .Trashes 86 | .VolumeIcon.icns 87 | .com.apple.timemachine.donotpresent 88 | .AppleDB 89 | .AppleDesktop 90 | Network Trash Folder 91 | Temporary Items 92 | .apdisk 93 | pids 94 | *.pid 95 | *.seed 96 | *.pid.lock 97 | Thumbs.db 98 | ehthumbs.db 99 | ehthumbs_vista.db 100 | Desktop.ini 101 | $RECYCLE.BIN 102 | *.cab 103 | *.msi 104 | *.msm 105 | *.msp 106 | *.lnk 107 | _book 108 | CertificateAuthorityCertificate.pem 109 | 110 | # Custom 111 | external-scripts/bin 112 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # TODO: replace these uglies with JS (mjs) scripts 4 | 5 | beginswith() { case $2 in "$1"*) true;; *) false;; esac; } 6 | 7 | if beginswith 'rebase' "$GIT_REFLOG_ACTION"; then 8 | echo 'husky-hook::commit-msg: skipped commit-msg hook due to rebase' 9 | exit 0 10 | fi 11 | 12 | NODE_NO_WARNINGS=1 commitlint -e 13 | if [ -z "$GAC_VERIFY_SIMPLE" ]; then npm run test:packages:all:unit; fi 14 | # TODO: bring back spellchecker: 15 | #echo 16 | #NODE_NO_WARNINGS=1 node spellcheck-commit.cjs 17 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # TODO: replace these uglies with JS (mjs) scripts 4 | 5 | beginswith() { case $2 in "$1"*) true;; *) false;; esac; } 6 | 7 | if beginswith 'rebase' "$GIT_REFLOG_ACTION"; then 8 | echo 'husky-hook::commit-msg: skipped pre-commit hook due to rebase' 9 | exit 0 10 | fi 11 | 12 | if [ -z "$GAC_VERIFY_SIMPLE" ]; then npm run lint:package; fi 13 | NODE_NO_WARNINGS=1 lint-staged --concurrent false --config lint-staged.config.mjs 14 | symbiote clean --env NODE_NO_WARNINGS=1 --only-empty-directories --hush --scope unlimited 15 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # TODO: replace these uglies with JS (mjs) scripts 4 | 5 | beginswith() { case $2 in "$1"*) true;; *) false;; esac; } 6 | prepend() { while read -r line; do echo "${1}${line}"; done; } 7 | 8 | if beginswith 'rebase' "$GIT_REFLOG_ACTION"; then 9 | echo 'husky-hook::pre-push: pushing commits in the middle of a rebase/merge/cherry-pick is not allowed!' 10 | exit 1 11 | fi 12 | 13 | echo 'husky-hook::pre-push: checking for commits that should not be pushed...' 14 | 15 | log=$(git log HEAD --oneline --not --remotes) 16 | 17 | set +e 18 | 19 | incompleteCommitsGrep=$(echo "$log" | grep -q -i -e 'mergeme' -e '\[WIP\]' -e '\[NOPUSH\]'; echo $?) 20 | 21 | # ? In the below lines, 'x' is passed as the "zero parameter" so "$@" spits out 22 | # ? the right stuff. Stuff like this won't be an issue when we switch this to JS 23 | 24 | interestingXxxFiles=$(git ls-tree -r --full-tree --name-only HEAD | grep -vE '(^|/)(\.husky|assets/templates/husky)/' | grep -vE '\.snap$') 25 | 26 | incompleteXxxFilesGrep=$(echo "$interestingXxxFiles" | xargs -d '\n' -P 0 sh -c 'if grep -q -F -e "XXX: " "$@"; then exit 255; else true; fi' 'x' 1>/dev/null 2>&1; echo $?) 27 | 28 | interestingPackageJsonFiles=$(echo "$interestingXxxFiles" | grep -E '^(packages/[^/]+/)?package\.json$') 29 | 30 | incompletePackageJsonFilesGrep=$(echo "$interestingPackageJsonFiles" | xargs -d '\n' -P 0 sh -c 'if grep -q -i -P -e "--assets-preset [^\x22]*?(\x27|((basic|cli|lib|react|nextjs) [^\x22]*){3})" "$@"; then exit 255; else true; fi' 'x' 1>/dev/null 2>&1; echo $?) 31 | 32 | interestingMdFiles=$(echo "$interestingXxxFiles" | grep '\.md$' | grep -vE '(^|/)(src|test|docs)/' | grep -vE '/CHANGELOG.md$') 33 | 34 | incompleteMdFilesGrep=$(echo "$interestingMdFiles" | xargs -d '\n' -P 0 sh -c 'if grep -q -i -F -e "-✄-" "$@"; then exit 255; else true; fi' 'x' 1>/dev/null 2>&1; echo $?) 35 | 36 | interestingTestFiles=$(echo "$interestingXxxFiles" | grep '\.test\.ts$') 37 | 38 | incompleteTestFilesGrep=$(echo "$interestingTestFiles" | xargs -d '\n' -P 0 sh -c 'if grep -q -i -E -e "(it|test|describe)\.only\(" "$@"; then exit 255; else true; fi' 'x' 1>/dev/null 2>&1; echo $?) 39 | 40 | set -e 41 | 42 | # ? Make sure no commits to be pushed contain "mergeme" etc in their headers, no 43 | # ? relevant markdown files contain "-✄-" in their contents, no files anywhere 44 | # ? anywhere contain "XXX: " in their contents, no test files contain 45 | # ? erroneously focused tests, and no package.json files have incomplete scripts 46 | if [ "$incompleteCommitsGrep" = 0 ] || [ "$incompleteMdFilesGrep" != 0 ] || [ "$incompleteXxxFilesGrep" != 0 ] || [ "$incompleteTestFilesGrep" != 0 ] || [ "$incompletePackageJsonFilesGrep" != 0 ]; then 47 | echo 'husky-hook::pre-push: BAD COMMIT(S) DETECTED!' 48 | echo 'husky-hook::pre-push: merge, delete, reword, or otherwise rectify the following commits before trying again:' 49 | 50 | if [ "$incompleteCommitsGrep" = 0 ]; then 51 | echo 52 | echo 'husky-hook::pre-push: incomplete commits (e.g. WIP, mergeme, NOPUSH):' 53 | echo 54 | echo "$log" | grep -i -e 'mergeme' -e '\[WIP\]' -e '\[NOPUSH\]' | prepend ' ⋗ ' 55 | fi 56 | 57 | if [ "$incompleteMdFilesGrep" != 0 ]; then 58 | echo 59 | echo 'husky-hook::pre-push: markdown files at HEAD with unmerged replacer regions:' 60 | echo 61 | echo "$interestingMdFiles" | xargs -d '\n' -P 0 grep -i -l -H -F -e '-✄-' | prepend ' ⋗ ' 62 | fi 63 | 64 | if [ "$incompleteXxxFilesGrep" != 0 ]; then 65 | echo 66 | echo 'husky-hook::pre-push: files at HEAD with "XXX" error comments:' 67 | echo 68 | echo "$interestingXxxFiles" | xargs -d '\n' -P 0 grep -l -H -F -e 'XXX: ' | prepend ' ⋗ ' 69 | fi 70 | 71 | if [ "$incompleteTestFilesGrep" != 0 ]; then 72 | echo 73 | echo 'husky-hook::pre-push: files at HEAD with erroneously focused tests:' 74 | echo 75 | echo "$interestingTestFiles" | xargs -d '\n' -P 0 grep -i -l -H -E -e '(it|test|describe)\.only\(' | prepend ' ⋗ ' 76 | fi 77 | 78 | if [ "$incompletePackageJsonFilesGrep" != 0 ]; then 79 | echo 80 | echo 'husky-hook::pre-push: package.json files at HEAD with incomplete scripts:' 81 | echo 82 | echo "$interestingPackageJsonFiles" | xargs -d '\n' -P 0 grep -i -l -H -P -e "--assets-preset [^\x22]*?(\x27|((basic|cli|lib|react|nextjs) [^\x22]*){3})" | prepend ' ⋗ ' 83 | fi 84 | 85 | echo 86 | exit 2; 87 | else 88 | echo 'husky-hook::pre-push: ✅' 89 | exit 0; 90 | fi 91 | -------------------------------------------------------------------------------- /.ncurc.cjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | const { createDebugLogger } = require('rejoinder'); 5 | 6 | const debug = createDebugLogger({ namespace: 'symbiote:config:ncurc' }); 7 | 8 | // * https://www.npmjs.com/package/npm-check-updates#configuration-files 9 | module.exports = { 10 | install: 'never', 11 | reject: [ 12 | // ? Reject any super-pinned dependencies (e.g. find-up~5 and execa~7) 13 | '*~*' 14 | ] 15 | }; 16 | 17 | debug('exported config: %O', module.exports); 18 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # * Paths below are ignored by prettier, remark, doctoc when called 2 | # * with `symbiote format` and `symbiote lint`. To have eslint ignore 3 | # * certain files, add them to an "ignores" block in eslint.config.js. To have 4 | # * tsc ignore certain files, exclude them from the appropriate tsc.*.json file. 5 | # * See symbiote's help text for more details. 6 | 7 | # ! Note that any pattern with a / in the beginning OR MIDDLE (but not end) will 8 | # ! be considered relative to this file ONLY. Matching subdirs will NOT match! 9 | # ! Otherwise, patterns will match entities in any directory or subdirectory. 10 | # ! Prepend ** (or **/) if advanced subdir matching of complex paths is desired. 11 | # ! See https://git-scm.com/docs/gitignore#_pattern_format 12 | 13 | # Ignore temporary files in any subdir by giving them a special name 14 | *.ignore 15 | *.ignore.* 16 | ignore.* 17 | 18 | # Ignore sensitive files in any subdir 19 | .env 20 | .npmrc 21 | *.local 22 | 23 | # Ignore transpiled source in any subdir (used for advanced debugging) 24 | .transpiled 25 | 26 | # Ignore relevant build artifacts in any subdir (with exceptions) 27 | *.tsbuildinfo 28 | # ? Preceding AND proceeding asterisks (**) are needed to match any build subdir 29 | # ? in monorepos and allow subsequent negations to be interpreted properly. 30 | **/build/** 31 | # ? This negation must end in "/**" to be interpreted properly. 32 | !**/src/**/build/** 33 | # ? Preceding AND proceeding asterisks (**) are needed to match any docs subdir 34 | # ? in monorepos and allow subsequent negations to be interpreted properly. 35 | **/docs/** 36 | # ? This negation must end in "/**" to be interpreted properly. 37 | !**/src/**/docs/** 38 | dist 39 | coverage 40 | .vercel 41 | .next 42 | next-env.d.ts 43 | CHANGELOG.md 44 | LICENSE 45 | LICENSE.md 46 | 47 | # Ignore relevant NPM artifacts in any subdir 48 | node_modules 49 | package-lock.json 50 | 51 | # Ignore test fixtures in any subdir (which may depend on remaining as they are) 52 | # ? This must end in "/**" to be interpreted properly. 53 | **/test/**/fixtures/** 54 | __*__ 55 | 56 | # Ignore things that prettier isn't good at in any subdir 57 | *.hbs 58 | 59 | # Ignore random nothingness in any subdir 60 | .DS_Store 61 | 62 | # Custom 63 | external-scripts/bin 64 | test/integration/assets/output-1.js 65 | -------------------------------------------------------------------------------- /.remarkrc.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 4 | import { assertEnvironment, moduleExport } from '@-xun/symbiote/assets/.remarkrc.mjs'; 5 | import { createDebugLogger } from 'rejoinder'; 6 | 7 | const debug = createDebugLogger({ namespace: 'symbiote:config:remarkrc' }); 8 | 9 | const config = deepMergeConfig(moduleExport(await assertEnvironment()), { 10 | // Any custom configs here will be deep merged with moduleExport 11 | }); 12 | 13 | export default config; 14 | 15 | debug('exported config: %O', config); 16 | -------------------------------------------------------------------------------- /.spellcheckignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.vscode/launch.example.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "type": "node", 5 | "name": "vscode-jest-tests.v2", 6 | "request": "launch", 7 | "program": "${workspaceFolder}/node_modules/.bin/jest", 8 | "args": [ 9 | "--runInBand", 10 | "--watchAll=false", 11 | "--testNamePattern", 12 | "${jest.testNamePattern}", 13 | "--runTestsByPath", 14 | "${jest.testFile}" 15 | ], 16 | "cwd": "${workspaceFolder}", 17 | "console": "integratedTerminal", 18 | "internalConsoleOptions": "neverOpen", 19 | "env": { 20 | "NODE_ENV": "test", 21 | "NODE_OPTIONS": "--no-warnings --experimental-vm-modules", 22 | "DEBUG_COLORS": "false" 23 | }, 24 | "windows": { 25 | "program": "${workspaceFolder}/node_modules/jest/bin/jest" 26 | }, 27 | 28 | // ! Note that these settings do NOT affect MANUALLY LAUNCHED debug 29 | // ! terminals! To affect stepping while using the debug terminal 30 | // ! manually, you'll need to configure settings.json (non-workspace) or 31 | // ! *.code-workspace (workspace) and set 32 | // ! `debug.javascript.terminalOptions.skipFiles/smartStep` appropriately. 33 | // * You MAY need to reload vscode/vscode-jest before changes take effect! 34 | // ? Set to false to step through node internals 35 | "smartStep": true, 36 | // ? Selectively comment out entries for deeper debugging 37 | "skipFiles": [ 38 | "/**", 39 | "**/node_modules/**" 40 | 41 | //"!**/node_modules/*jest*/**" 42 | //"!**/node_modules/@-xun/**" 43 | ] 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /.vscode/tasks.example.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "lint: discover problems", 8 | "type": "process", 9 | "command": "npx", 10 | "args": [ 11 | "symbiote", 12 | "lint", 13 | "--scope=unlimited", 14 | "--linter=eslint", 15 | "--linter=tsc", 16 | "--allow-warning-comments=false" 17 | ], 18 | "presentation": { 19 | "echo": true, 20 | "reveal": "never" 21 | }, 22 | "echoCommand": true, 23 | "icon": { "id": "zap", "color": "terminal.ansiCyan" }, 24 | "problemMatcher": ["$eslint-stylish", "$tsc"] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /ARCHITECTURE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 📐 Project Architecture 4 | 5 | Before continuing with this document, see the document on the [generic project 6 | architecture][1] expected by projects (like this repository) that leverage 7 | [symbiote][2]. 8 | 9 | What follows are any notable additions and/or deviations from the aforementioned 10 | document. 11 | 12 |
13 | 14 | --- 15 | 16 |
17 | 18 | 19 | 20 | There are as of yet no notable deviations or additions. See the linked document 21 | (above) for information on the architecture of this project. 22 | 23 | [1]: https://github.com/Xunnamius/symbiote/wiki/Generic-Project-Architecture 24 | [2]: https://github.com/Xunnamius/symbiote 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Hi there! First off, we're thrilled 🤩 you want contribute to this project! 4 | 5 | First time contributor to a GitHub project? If you could use some help getting 6 | started, [take a look at this quick and easy guide][how-to-contribute]. 💜 7 | 8 | ## Briefly: Submitting a Pull Request (Pr) 9 | 10 | > See also: [CODE_OF_CONDUCT.md][code-of-conduct] 11 | 12 | This repository uses a [fully automated][github-actions] [continuous 13 | linting][husky-cl] (CL), integration testing (CI), and deployment (CD) 14 | [xpipeline][xpipeline]-based pipeline for integrating PRs and publishing 15 | releases. The neat thing about a fully automated pipeline is that anyone 16 | anywhere can make a contribution quickly and with minimal tedium. 17 | 18 | This repository makes extensive use of [debug][pkg-debug]. Should you wish to 19 | view all possible debugging output, [export 20 | `DEBUG='*,*:*'`][pkg-debug-wildcards]. 21 | 22 | The ideal contributor flow is as follows: 23 | 24 | 1. [Fork][fork] this repository and [clone it locally][how-to-clone]. 25 | - If there is a custom Docker image available for this project and you're 26 | comfortable with Docker, consider using it instead. 27 | 2. Configure and install dependencies with `npm ci`. 28 | - You use `npm ci` here instead of `npm install` to [prevent unnecessary 29 | updates to `package.json` and `package-lock.json`][npm-ci], but if it makes 30 | more sense to use `npm install` feel free to use that instead. 31 | - **If you're getting an EINTEGRITY error from npm, you need to delete 32 | package-lock.json before running `npm install` (not `npm ci`).** 33 | - If `.env.default` exists, consider copying it to `.env` for sensible 34 | pre-configured defaults. 35 | 3. Before making any changes, ensure all unit tests are passing with 36 | `npm run test`. 37 | 4. _(optional but recommended)_ Create a new branch, usually off `main`. 38 | - Example: `git checkout -b contrib-feature-1`. 39 | 5. Make your changes and commit. Your work will be checked as you commit; any 40 | problems will abort the commit/push attempt. 41 | - Ensure any new tests still pass even when the `DEBUG` environment variable 42 | is defined. 43 | 6. Push your commits to your fork and, when you're ready, [_fearlessly_ submit 44 | your PR][pr-compare]! Your changes will be tested in our CI pipeline. 45 | 7. Pat yourself on the back! Your hard work is well on its way to being reviewed 46 | and, if everything looks good, merged and released 🚀 47 | 48 | Additionally, there are a few things you can do to greatly increase the 49 | likelihood your PR passes review: 50 | 51 | - **Do** [open an issue][choose-new-issue] and discuss your proposed changes (to 52 | prevent wasting your valuable time, e.g. _maybe we're already working on a 53 | fix!_), and [search][open-issues] to see if there are any existing issues 54 | related to your concerns. 55 | - **Do** practice [atomic committing][atomic-commits]. 56 | - **Do not** reduce code coverage ([codecov][codecov] checks are performed 57 | during CI). 58 | - **Do** [follow convention][conventional-commits] when coming up with your 59 | commit messages. 60 | - **Do not** circumvent CL, i.e. automated pre-commit linting, formatting, and 61 | unit testing. 62 | - **Do** ensure `README.md` and other documentation that isn't autogenerated is 63 | kept consistent with your changes. 64 | - **Do not** create a PR to introduce [_purely_ cosmetic 65 | commits][cosmetic-commits]. 66 | - Code de-duplication and other potential optimizations we **do not** consider 67 | _purely_ cosmetic 🙂 68 | - **Do** keep your PR as narrow and focused as possible. 69 | - If you ran `npm install` instead of `npm ci` and it updated `package.json` 70 | or `package-lock.json` and those updates have nothing to do with your PR 71 | (e.g. random nested deps were updated), **do not** stage changes to those 72 | files. 73 | - If there are multiple related changes to be made but (1) they do not 74 | immediately depend on one another or (2) one implements extended/alternative 75 | functionality based on the other, consider submitting them as separate PRs 76 | instead. 77 | 78 | At this point, you're ready to create your PR and ✨ contribute ✨! 79 | 80 | [atomic-commits]: https://www.codewithjason.com/atomic-commits-testing 81 | [choose-new-issue]: 82 | https://github.com/Xunnamius/next-test-api-route-handler/issues/new/choose 83 | [code-of-conduct]: 84 | https://github.com/Xunnamius/next-test-api-route-handler/.github/CODE_OF_CONDUCT.md 85 | [codecov]: https://about.codecov.io 86 | [conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0#summary 87 | [cosmetic-commits]: 88 | https://github.com/rails/rails/pull/13771#issuecomment-32746700 89 | [fork]: https://github.com/Xunnamius/next-test-api-route-handler/fork 90 | [github-actions]: https://github.com/features/actions 91 | [how-to-clone]: 92 | https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository 93 | [how-to-contribute]: https://www.dataschool.io/how-to-contribute-on-github 94 | [husky-cl]: 95 | https://github.com/Xunnamius/next-test-api-route-handler/tree/main/.husky 96 | [npm-ci]: https://docs.npmjs.com/cli/v6/commands/npm-ci 97 | [open-issues]: 98 | https://github.com/Xunnamius/next-test-api-route-handler/issues?q= 99 | [pkg-debug]: https://www.npmjs.com/package/debug 100 | [pkg-debug-wildcards]: https://www.npmjs.com/package/debug#wildcards 101 | [pr-compare]: https://github.com/Xunnamius/next-test-api-route-handler/compare 102 | [xpipeline]: https://github.com/Xunnamius/xpipeline#readme 103 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Bernard Dickens III 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security ☠️ [![Known Vulnerabilities][2]][1] 2 | 3 | If the issue is related to a public alert from OWASP/GitHub/Dependabot/CVE/etc 4 | and [does not already have an open issue][3], feel free to [open a new 5 | issue][4]. Otherwise, please report any security vulnerability or other 6 | security-related incident or sensitive subject to us [via private vulnerability 7 | disclosure through GitHub][5] or, if that fails, [via email][6]. 8 | 9 | Thank you for your contribution! 10 | 11 | [1]: https://snyk.io/test/github/Xunnamius/next-test-api-route-handler 12 | [2]: https://snyk.io/test/github/Xunnamius/next-test-api-route-handler/badge.svg 13 | [3]: https://github.com/Xunnamius/next-test-api-route-handler/issues?q= 14 | [4]: https://github.com/Xunnamius/next-test-api-route-handler/issues/new/choose 15 | [5]: 16 | https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability 17 | [6]: 18 | mailto:security@ergodark.com?subject=ALERT%3A%20SECURITY%20INCIDENT%3A%20%28five%20word%20summary%29 19 | -------------------------------------------------------------------------------- /apollo_test_raw: -------------------------------------------------------------------------------- 1 | /* File: examples/api-routes-apollo-server-and-client/tests/integration.test.js */ 2 | 3 | import { testApiHandler } from 'next-test-api-route-handler'; 4 | // Import the handler under test from the pages/api directory 5 | import * as pagesHandler from '../pages/api/graphql'; 6 | 7 | describe('my-test (pages router)', () => { 8 | it('does what I want 1', async () => { 9 | expect.hasAssertions(); 10 | 11 | await testApiHandler({ 12 | pagesHandler, 13 | url: '/api/graphql', // Set the request url to the path graphql expects 14 | test: async ({ fetch }) => { 15 | const query = `query ViewerQuery { 16 | viewer { 17 | id 18 | name 19 | status 20 | } 21 | }`; 22 | 23 | const res = await fetch({ 24 | method: 'POST', 25 | headers: { 26 | 'content-type': 'application/json' // Must use correct content type 27 | }, 28 | body: JSON.stringify({ query }) 29 | }); 30 | 31 | await expect(res.json()).resolves.toStrictEqual({ 32 | data: { viewer: { id: '1', name: 'John Smith', status: 'cached' } } 33 | }); 34 | } 35 | }); 36 | }); 37 | 38 | it('does what I want 2', async () => { 39 | expect.hasAssertions(); 40 | 41 | await testApiHandler({ 42 | pagesHandler, 43 | url: '/api/graphql', // Set the request url to the path graphql expects 44 | test: async ({ fetch }) => { 45 | const query = `query ViewerQuery { 46 | viewer { 47 | id 48 | name 49 | status 50 | } 51 | }`; 52 | 53 | const res = await fetch({ 54 | method: 'POST', 55 | headers: { 56 | 'content-type': 'application/json' // Must use correct content type 57 | }, 58 | body: JSON.stringify({ query }) 59 | }); 60 | 61 | await expect(res.json()).resolves.toStrictEqual({ 62 | data: { viewer: { id: '1', name: 'John Smith', status: 'cached' } } 63 | }); 64 | } 65 | }); 66 | }); 67 | 68 | it('does what I want 3', async () => { 69 | expect.hasAssertions(); 70 | 71 | await testApiHandler({ 72 | pagesHandler, 73 | url: '/api/graphql', // Set the request url to the path graphql expects 74 | test: async ({ fetch }) => { 75 | const query = `query ViewerQuery { 76 | viewer { 77 | id 78 | name 79 | status 80 | } 81 | }`; 82 | 83 | const res = await fetch({ 84 | method: 'POST', 85 | headers: { 86 | 'content-type': 'application/json' // Must use correct content type 87 | }, 88 | body: JSON.stringify({ query }) 89 | }); 90 | 91 | await expect(res.json()).resolves.toStrictEqual({ 92 | data: { viewer: { id: '1', name: 'John Smith', status: 'cached' } } 93 | }); 94 | } 95 | }); 96 | }); 97 | }); 98 | -------------------------------------------------------------------------------- /apollo_test_raw_app_route: -------------------------------------------------------------------------------- 1 | /* File: app/api/graphql/route.js */ 2 | 3 | import { ApolloServer } from '@apollo/server'; 4 | import { startServerAndCreateNextHandler } from '@as-integrations/next'; 5 | import { gql } from 'graphql-tag'; 6 | 7 | const resolvers = { 8 | Query: { 9 | hello: () => 'world' 10 | } 11 | }; 12 | 13 | const typeDefs = gql` 14 | type Query { 15 | hello: String 16 | } 17 | `; 18 | 19 | const server = new ApolloServer({ 20 | resolvers, 21 | typeDefs 22 | }); 23 | 24 | const handler = startServerAndCreateNextHandler(server); 25 | 26 | export { handler as GET, handler as POST }; 27 | -------------------------------------------------------------------------------- /apollo_test_raw_app_test: -------------------------------------------------------------------------------- 1 | /* File: tests/integration.test.js */ 2 | 3 | import { testApiHandler } from 'next-test-api-route-handler'; 4 | // Import the handler under test from the app/api directory 5 | import * as appHandler from '../app/api/graphql/route'; 6 | 7 | describe('my-test (app router)', () => { 8 | it('does what I want 1', async () => { 9 | expect.hasAssertions(); 10 | 11 | await testApiHandler({ 12 | appHandler, 13 | test: async ({ fetch }) => { 14 | const query = `query { hello }`; 15 | 16 | const res = await fetch({ 17 | method: 'POST', 18 | headers: { 19 | 'content-type': 'application/json' // Must use correct content type 20 | }, 21 | body: JSON.stringify({ query }) 22 | }); 23 | 24 | await expect(res.json()).resolves.toStrictEqual({ 25 | data: { hello: 'world' } 26 | }); 27 | } 28 | }); 29 | }); 30 | 31 | it('does what I want 2', async () => { 32 | expect.hasAssertions(); 33 | 34 | await testApiHandler({ 35 | appHandler, 36 | test: async ({ fetch }) => { 37 | const query = `query { hello }`; 38 | 39 | const res = await fetch({ 40 | method: 'POST', 41 | headers: { 42 | 'content-type': 'application/json' // Must use correct content type 43 | }, 44 | body: JSON.stringify({ query }) 45 | }); 46 | 47 | await expect(res.json()).resolves.toStrictEqual({ 48 | data: { hello: 'world' } 49 | }); 50 | } 51 | }); 52 | }); 53 | 54 | it('does what I want 3', async () => { 55 | expect.hasAssertions(); 56 | 57 | await testApiHandler({ 58 | appHandler, 59 | test: async ({ fetch }) => { 60 | const query = `query { hello }`; 61 | 62 | const res = await fetch({ 63 | method: 'POST', 64 | headers: { 65 | 'content-type': 'application/json' // Must use correct content type 66 | }, 67 | body: JSON.stringify({ query }) 68 | }); 69 | 70 | await expect(res.json()).resolves.toStrictEqual({ 71 | data: { hello: 'world' } 72 | }); 73 | } 74 | }); 75 | }); 76 | }); 77 | -------------------------------------------------------------------------------- /babel.config.cjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | const { deepMergeConfig } = require('@-xun/symbiote/assets'); 5 | 6 | const { 7 | assertEnvironment, 8 | moduleExport 9 | } = require('@-xun/symbiote/assets/babel.config.cjs'); 10 | 11 | const { createDebugLogger } = require('rejoinder'); 12 | 13 | const debug = createDebugLogger({ namespace: 'symbiote:config:babel' }); 14 | 15 | module.exports = deepMergeConfig( 16 | moduleExport({ 17 | derivedAliases: getBabelAliases(), 18 | ...assertEnvironment({ projectRoot: __dirname }) 19 | }), 20 | { 21 | // Any custom configs here will be deep merged with moduleExport's result 22 | // You may wish to enable explicit exports references for improved testing 23 | // DX, but be aware that it is currently a wee buggy as of 5/2025 (fix it!) 24 | // 25 | // env: { 26 | // test: { 27 | // plugins: ['babel-plugin-explicit-exports-references'] 28 | // } 29 | // } 30 | } 31 | ); 32 | 33 | // TODO: delete this 34 | if (process.env.EXTERNAL_DELETE_THIS) { 35 | // @ts-expect-error: delete all of this 36 | module.exports.env['production-cjs'].plugins[0][1].replaceExtensions[ 37 | '^../test/util.js$' 38 | ] = './util.js'; 39 | } 40 | 41 | debug('exported config: %O', module.exports); 42 | 43 | function getBabelAliases() { 44 | // ! These aliases are auto-generated by symbiote. Instead of modifying them 45 | // ! directly, consider regenerating aliases across the entire project with: 46 | // ! `npx symbiote project renovate --regenerate-assets --assets-preset ...` 47 | return { 48 | '^universe:(.+)$': './src/$1', 49 | '^universe$': './src/index.js', 50 | '^testverse:(.+)$': './test/$1', 51 | '^typeverse:(.+)$': './types/$1', 52 | '^rootverse:(.+)$': './$1' 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /commitlint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 5 | import { moduleExport } from '@-xun/symbiote/assets/commitlint.config.mjs'; 6 | import { createDebugLogger } from 'rejoinder'; 7 | 8 | const debug = createDebugLogger({ namespace: 'symbiote:config:commitlint' }); 9 | 10 | const config = deepMergeConfig(moduleExport(), { 11 | // Any custom configs here will be deep merged with moduleExport's result 12 | }); 13 | 14 | export default config; 15 | 16 | debug('exported config: %O', config); 17 | -------------------------------------------------------------------------------- /conventional.config.cjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | const { 5 | assertEnvironment, 6 | moduleExport 7 | } = require('@-xun/symbiote/assets/conventional.config.cjs'); 8 | 9 | const { createDebugLogger } = require('rejoinder'); 10 | 11 | const debug = createDebugLogger({ namespace: 'symbiote:config:conventional' }); 12 | 13 | module.exports = moduleExport({ 14 | ...assertEnvironment(), 15 | configOverrides: { 16 | // Any custom configs here will be deep merged with moduleExport with 17 | // special considerations for certain keys. `configOverrides` can also 18 | // be a function instead of an object. 19 | } 20 | }); 21 | 22 | debug('exported config: %O', module.exports); 23 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | **next-test-api-route-handler** 2 | 3 | *** 4 | 5 | # next-test-api-route-handler 6 | 7 | ## Modules 8 | 9 | - [src](src/README.md) 10 | - [test/setup](test/setup/README.md) 11 | - [test/util](test/util/README.md) 12 | -------------------------------------------------------------------------------- /docs/src/README.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../README.md) / src 6 | 7 | # src 8 | 9 | ## Interfaces 10 | 11 | - [NtarhInit](interfaces/NtarhInit.md) 12 | - [NtarhInitAppRouter](interfaces/NtarhInitAppRouter.md) 13 | - [NtarhInitPagesRouter](interfaces/NtarhInitPagesRouter.md) 14 | 15 | ## Functions 16 | 17 | - [testApiHandler](functions/testApiHandler.md) 18 | -------------------------------------------------------------------------------- /docs/src/functions/testApiHandler.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../README.md) / [src](../README.md) / testApiHandler 6 | 7 | # Function: testApiHandler() 8 | 9 | > **testApiHandler**\<`NextResponseJsonType`\>(`__namedParameters`): `Promise`\<`void`\> 10 | 11 | Defined in: [src/index.ts:298](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/src/index.ts#L298) 12 | 13 | Uses Next's internal `apiResolver` (for Pages Router) or an 14 | `AppRouteRouteModule` instance (for App Router) to execute api route handlers 15 | in a Next-like testing environment. 16 | 17 | ## Type Parameters 18 | 19 | ### NextResponseJsonType 20 | 21 | `NextResponseJsonType` = `any` 22 | 23 | ## Parameters 24 | 25 | ### \_\_namedParameters 26 | 27 | [`NtarhInitAppRouter`](../interfaces/NtarhInitAppRouter.md)\<`NextResponseJsonType`\> | [`NtarhInitPagesRouter`](../interfaces/NtarhInitPagesRouter.md)\<`NextResponseJsonType`\> 28 | 29 | ## Returns 30 | 31 | `Promise`\<`void`\> 32 | -------------------------------------------------------------------------------- /docs/src/interfaces/NtarhInit.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../README.md) / [src](../README.md) / NtarhInit 6 | 7 | # Interface: NtarhInit\ 8 | 9 | Defined in: [src/index.ts:132](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/src/index.ts#L132) 10 | 11 | ## Extended by 12 | 13 | - [`NtarhInitAppRouter`](NtarhInitAppRouter.md) 14 | - [`NtarhInitPagesRouter`](NtarhInitPagesRouter.md) 15 | 16 | ## Type Parameters 17 | 18 | ### NextResponseJsonType 19 | 20 | `NextResponseJsonType` = `unknown` 21 | 22 | ## Properties 23 | 24 | ### rejectOnHandlerError? 25 | 26 | > `optional` **rejectOnHandlerError**: `boolean` 27 | 28 | Defined in: [src/index.ts:145](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/src/index.ts#L145) 29 | 30 | If `false`, errors thrown from within a handler are kicked up to Next.js's 31 | resolver to deal with, which is what would happen in production. If `true`, 32 | the [testApiHandler](../functions/testApiHandler.md) function will reject immediately instead. 33 | 34 | You should use `rejectOnHandlerError` whenever you want to manually handle 35 | an error that bubbles up from your handler (which is especially true if 36 | you're using `expect` _within_ your handler) or when you notice a false 37 | negative despite exceptions being thrown. 38 | 39 | #### Default 40 | 41 | ```ts 42 | false 43 | ``` 44 | 45 | *** 46 | 47 | ### test() 48 | 49 | > **test**: (`parameters`) => `Promisable`\<`void`\> 50 | 51 | Defined in: [src/index.ts:151](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/src/index.ts#L151) 52 | 53 | `test` is a function that runs your test assertions. This function receives 54 | one destructured parameter: `fetch`, which is equivalent to 55 | `globalThis.fetch` but with the first parameter omitted. 56 | 57 | #### Parameters 58 | 59 | ##### parameters 60 | 61 | ###### fetch 62 | 63 | (`customInit`?) => `FetchReturnType`\<`NextResponseJsonType`\> 64 | 65 | #### Returns 66 | 67 | `Promisable`\<`void`\> 68 | -------------------------------------------------------------------------------- /docs/test/setup/README.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../README.md) / test/setup 6 | 7 | # test/setup 8 | -------------------------------------------------------------------------------- /docs/test/util/classes/MockedExitError.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockedExitError 6 | 7 | # Class: MockedExitError 8 | 9 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:7 10 | 11 | Represents a call to `process.exit` when said function was mocked by 12 | `withMockedExit`. 13 | 14 | ## Extends 15 | 16 | - `Error` 17 | 18 | ## Constructors 19 | 20 | ### Constructor 21 | 22 | > **new MockedExitError**(`code`): `MockedExitError` 23 | 24 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:13 25 | 26 | Represents a call to `process.exit` when said function was mocked by 27 | `withMockedExit`. 28 | 29 | #### Parameters 30 | 31 | ##### code 32 | 33 | `undefined` | `null` | `string` | `number` 34 | 35 | #### Returns 36 | 37 | `MockedExitError` 38 | 39 | #### Overrides 40 | 41 | `Error.constructor` 42 | 43 | ### Constructor 44 | 45 | > **new MockedExitError**(`code`, `message`, `superOptions`): `MockedExitError` 46 | 47 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:18 48 | 49 | This constructor syntax is used by subclasses when calling this constructor 50 | via `super`. 51 | 52 | #### Parameters 53 | 54 | ##### code 55 | 56 | `undefined` | `null` | `string` | `number` 57 | 58 | ##### message 59 | 60 | `string` 61 | 62 | ##### superOptions 63 | 64 | `ErrorOptions` 65 | 66 | #### Returns 67 | 68 | `MockedExitError` 69 | 70 | #### Overrides 71 | 72 | `Error.constructor` 73 | 74 | ## Properties 75 | 76 | ### \[$type\] 77 | 78 | > **\[$type\]**: `symbol`[] 79 | 80 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:8 81 | 82 | *** 83 | 84 | ### cause? 85 | 86 | > `optional` **cause**: `unknown` 87 | 88 | Defined in: node\_modules/typescript/lib/lib.es2022.error.d.ts:26 89 | 90 | #### Inherited from 91 | 92 | `Error.cause` 93 | 94 | *** 95 | 96 | ### message 97 | 98 | > **message**: `string` 99 | 100 | Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1077 101 | 102 | #### Inherited from 103 | 104 | `Error.message` 105 | 106 | *** 107 | 108 | ### name 109 | 110 | > **name**: `string` 111 | 112 | Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1076 113 | 114 | #### Inherited from 115 | 116 | `Error.name` 117 | 118 | *** 119 | 120 | ### stack? 121 | 122 | > `optional` **stack**: `string` 123 | 124 | Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1078 125 | 126 | #### Inherited from 127 | 128 | `Error.stack` 129 | 130 | *** 131 | 132 | ### prepareStackTrace()? 133 | 134 | > `static` `optional` **prepareStackTrace**: (`err`, `stackTraces`) => `any` 135 | 136 | Defined in: node\_modules/@types/node/globals.d.ts:143 137 | 138 | Optional override for formatting stack traces 139 | 140 | #### Parameters 141 | 142 | ##### err 143 | 144 | `Error` 145 | 146 | ##### stackTraces 147 | 148 | `CallSite`[] 149 | 150 | #### Returns 151 | 152 | `any` 153 | 154 | #### See 155 | 156 | https://v8.dev/docs/stack-trace-api#customizing-stack-traces 157 | 158 | #### Inherited from 159 | 160 | `Error.prepareStackTrace` 161 | 162 | *** 163 | 164 | ### stackTraceLimit 165 | 166 | > `static` **stackTraceLimit**: `number` 167 | 168 | Defined in: node\_modules/@types/node/globals.d.ts:145 169 | 170 | #### Inherited from 171 | 172 | `Error.stackTraceLimit` 173 | 174 | ## Methods 175 | 176 | ### captureStackTrace() 177 | 178 | > `static` **captureStackTrace**(`targetObject`, `constructorOpt`?): `void` 179 | 180 | Defined in: node\_modules/@types/node/globals.d.ts:136 181 | 182 | Create .stack property on a target object 183 | 184 | #### Parameters 185 | 186 | ##### targetObject 187 | 188 | `object` 189 | 190 | ##### constructorOpt? 191 | 192 | `Function` 193 | 194 | #### Returns 195 | 196 | `void` 197 | 198 | #### Inherited from 199 | 200 | `Error.captureStackTrace` 201 | -------------------------------------------------------------------------------- /docs/test/util/functions/asMocked.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / asMocked 6 | 7 | # Function: asMocked() 8 | 9 | ## Call Signature 10 | 11 | > **asMocked**\<`T`\>(`options`?): `MaybeMockedDeep`\<`T`\> 12 | 13 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:47 14 | 15 | Return a function representing `T` but wrapped with Jest mock definitions. 16 | Pass `{shallow: true}` as the only parameter to disable the deep mocking of 17 | `T`, which otherwise occurs by default. 18 | 19 | This is a more powerful version of Jest's own jest.mocked and 20 | jest.MockedFn. 21 | 22 | ### Type Parameters 23 | 24 | #### T 25 | 26 | `T` *extends* (...`args`) => `any` 27 | 28 | ### Parameters 29 | 30 | #### options? 31 | 32 | ##### shallow? 33 | 34 | `false` 35 | 36 | ### Returns 37 | 38 | `MaybeMockedDeep`\<`T`\> 39 | 40 | ### Example 41 | 42 | ```ts 43 | import type { MyFunctionType } from "./library"; 44 | jest.mock("./library"); 45 | 46 | const mockRepresentingMyFunctionType = asMocked(); 47 | // ... 48 | expect(mockRepresentingMyFunctionType.mock.calls[0][0]).toBe(42); 49 | ``` 50 | 51 | ## Call Signature 52 | 53 | > **asMocked**\<`T`\>(`options`): `MaybeMocked`\<`T`\> 54 | 55 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:66 56 | 57 | Return a function representing `T` but wrapped (shallowly) with Jest mock 58 | definitions. 59 | 60 | This is a more powerful version of Jest's own jest.mocked and 61 | jest.MockedFn. 62 | 63 | ### Type Parameters 64 | 65 | #### T 66 | 67 | `T` *extends* (...`args`) => `any` 68 | 69 | ### Parameters 70 | 71 | #### options 72 | 73 | ##### shallow 74 | 75 | `true` 76 | 77 | ### Returns 78 | 79 | `MaybeMocked`\<`T`\> 80 | 81 | ### Example 82 | 83 | ```ts 84 | import type { MyFunctionType } from "./library"; 85 | jest.mock("./library"); 86 | 87 | const mockRepresentingMyFunctionType = asMocked({ shallow: true }); 88 | // ... 89 | expect(mockRepresentingMyFunctionType.mock.calls[0][0]).toBe(42); 90 | ``` 91 | 92 | ## Call Signature 93 | 94 | > **asMocked**\<`T`\>(`source`, `options`?): `MaybeMockedDeep`\<`T`\> 95 | 96 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:83 97 | 98 | Wrap the non-nullish `source` with Jest mock definitions. Pass `{shallow: 99 | true}` as the second parameter to disable the default deep mocking behavior. 100 | 101 | This is a more powerful version of Jest's own jest.mocked function. 102 | 103 | ### Type Parameters 104 | 105 | #### T 106 | 107 | `T` *extends* `object` 108 | 109 | ### Parameters 110 | 111 | #### source 112 | 113 | `T` 114 | 115 | #### options? 116 | 117 | ##### shallow 118 | 119 | `false` 120 | 121 | ### Returns 122 | 123 | `MaybeMockedDeep`\<`T`\> 124 | 125 | ### Example 126 | 127 | ```ts 128 | import { myFunction } from "./library"; 129 | jest.mock("./library"); 130 | 131 | const mockMyFunction = asMocked(myFunction); 132 | expect(mockMyFunction.mock.calls[0][0]).toBe(42); 133 | ``` 134 | 135 | ## Call Signature 136 | 137 | > **asMocked**\<`T`\>(`source`, `options`): `MaybeMocked`\<`T`\> 138 | 139 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:99 140 | 141 | Shallowly wrap the non-nullish `source` with Jest mock definitions. 142 | 143 | This is a more powerful version of Jest's own jest.mocked function. 144 | 145 | ### Type Parameters 146 | 147 | #### T 148 | 149 | `T` *extends* `object` 150 | 151 | ### Parameters 152 | 153 | #### source 154 | 155 | `T` 156 | 157 | #### options 158 | 159 | ##### shallow 160 | 161 | `true` 162 | 163 | ### Returns 164 | 165 | `MaybeMocked`\<`T`\> 166 | 167 | ### Example 168 | 169 | ```ts 170 | import { myFunction } from "./library"; 171 | jest.mock("./library"); 172 | 173 | const mockMyFunction = asMocked(myFunction, { shallow: true }); 174 | expect(mockMyFunction.mock.calls[0][0]).toBe(42); 175 | ``` 176 | 177 | ## Call Signature 178 | 179 | > **asMocked**\<`T`\>(...`args`): `MaybeMockedDeep`\<`T`\> \| `MaybeMocked`\<`T`\> 180 | 181 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:116 182 | 183 | Wrap the non-nullish `source` (or `T` itself is `source` is omitted) with 184 | Jest mock definitions. 185 | 186 | This is a more powerful version of Jest's own jest.mocked function. 187 | 188 | ### Type Parameters 189 | 190 | #### T 191 | 192 | `T` *extends* `object` 193 | 194 | ### Parameters 195 | 196 | #### args 197 | 198 | \[`object`\] | \[`T`, `object`\] 199 | 200 | ### Returns 201 | 202 | `MaybeMockedDeep`\<`T`\> \| `MaybeMocked`\<`T`\> 203 | 204 | ### Example 205 | 206 | ```ts 207 | import { myFunction } from "./library"; 208 | jest.mock("./library"); 209 | 210 | const mockMyFunction = asMocked(myFunction); 211 | expect(mockMyFunction.mock.calls[0][0]).toBe(42); 212 | ``` 213 | -------------------------------------------------------------------------------- /docs/test/util/functions/describeRootFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / describeRootFixture 6 | 7 | # Function: describeRootFixture() 8 | 9 | > **describeRootFixture**(): [`DescribeRootFixture`](../type-aliases/DescribeRootFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/describe-root.d.ts:46 12 | 13 | This fixture outputs debug information describing the runtime environment. 14 | 15 | This fixture is treated specially in two ways: 16 | 17 | 1. If a fixture with the name `'describe-root'` is not included in the 18 | `fixtures` array parameter of `withMockedFixtures`, _this fixture will be 19 | automatically appended_ to said array. 20 | 21 | 2. _This fixture will always run_, even when an error occurs in an earlier 22 | fixture. 23 | 24 | ## Returns 25 | 26 | [`DescribeRootFixture`](../type-aliases/DescribeRootFixture.md) 27 | -------------------------------------------------------------------------------- /docs/test/util/functions/dummyDirectoriesFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyDirectoriesFixture 6 | 7 | # Function: dummyDirectoriesFixture() 8 | 9 | > **dummyDirectoriesFixture**(): [`DummyDirectoriesFixture`](../type-aliases/DummyDirectoriesFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-directories.d.ts:48 12 | 13 | This fixture writes out the directories described by `initialDirectories` to 14 | the filesystem. Subdirectory paths of any depth are allowed, any non-existent 15 | path components will be created if they do not already exist, and any 16 | existing components will be ignored. This is similar to the behavior of 17 | `mkdir -p` on Linux. 18 | 19 | ## Returns 20 | 21 | [`DummyDirectoriesFixture`](../type-aliases/DummyDirectoriesFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/functions/dummyFilesFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyFilesFixture 6 | 7 | # Function: dummyFilesFixture() 8 | 9 | > **dummyFilesFixture**(): [`DummyFilesFixture`](../type-aliases/DummyFilesFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-files.d.ts:52 12 | 13 | This fixture writes out the files described by `initialVirtualFiles` to the 14 | filesystem. Paths of any depth are allowed, any non-existent path components 15 | (directories) will be created if they do not already exist, and any existing 16 | components will be ignored. 17 | 18 | This is similar to the behavior of `mkdir -p $(dirname filepath) && echo 19 | "contents" > filepath` on Linux. 20 | 21 | ## Returns 22 | 23 | [`DummyFilesFixture`](../type-aliases/DummyFilesFixture.md) 24 | -------------------------------------------------------------------------------- /docs/test/util/functions/dummyNpmPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyNpmPackageFixture 6 | 7 | # Function: dummyNpmPackageFixture() 8 | 9 | > **dummyNpmPackageFixture**(): [`DummyNpmPackageFixture`](../type-aliases/DummyNpmPackageFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-npm-package.d.ts:77 12 | 13 | This fixture initializes the dummy root directory as a NPM package with a 14 | `package.json` file (optionally described by `initialVirtualFiles`) and 15 | node_modules subdirectory. If said `package.json` file contains any 16 | dependencies, they will be installed courtesy of `npm install`. Additional 17 | packages can also be installed via 18 | [DummyNpmPackageFixtureOptions.additionalPackagesToInstall](../type-aliases/DummyNpmPackageFixtureOptions.md). 19 | 20 | All packages are always installed with `--force`. 21 | 22 | If a `packageUnderTest` is provided, and it is namespaced (e.g. 23 | "@-xun/symbiote"), an empty directory will be created using the namespace as 24 | its name (e.g. `node_modules/@-xun`). 25 | 26 | Note that the `packageUnderTest` is not the same thing as the dummy root NPM 27 | package; the latter typically imports/tests the former. 28 | 29 | ## Returns 30 | 31 | [`DummyNpmPackageFixture`](../type-aliases/DummyNpmPackageFixture.md) 32 | -------------------------------------------------------------------------------- /docs/test/util/functions/ensurePackageHasBeenBuilt.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / ensurePackageHasBeenBuilt 6 | 7 | # Function: ensurePackageHasBeenBuilt() 8 | 9 | > **ensurePackageHasBeenBuilt**(`packageRoot`, `packageName`, `packageExports`): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:186 12 | 13 | This function will throw if at least one of `packageName`'s entry points 14 | (relative to `packageRoot` and as defined in `packageExports`, are 15 | inaccessible. If this package has no entry points, this function becomes a 16 | no-op. 17 | 18 | ## Parameters 19 | 20 | ### packageRoot 21 | 22 | `AbsolutePath` 23 | 24 | ### packageName 25 | 26 | `undefined` | `string` 27 | 28 | ### packageExports 29 | 30 | `undefined` | `Exports` 31 | 32 | ## Returns 33 | 34 | `Promise`\<`void`\> 35 | -------------------------------------------------------------------------------- /docs/test/util/functions/getNextjsReactPeerDependencies.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / getNextjsReactPeerDependencies 6 | 7 | # Function: getNextjsReactPeerDependencies() 8 | 9 | > **getNextjsReactPeerDependencies**(`npmInstallNextJsString`): `Promise`\<`string`[]\> 10 | 11 | Defined in: [test/util.ts:28](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/test/util.ts#L28) 12 | 13 | Since some versions of Next.js are released with flawed 14 | `package.json::peerDependencies`, sometimes we need to ensure the correct 15 | versions of Next.js's peer dependencies are actually installed. 16 | 17 | ## Parameters 18 | 19 | ### npmInstallNextJsString 20 | 21 | `string` 22 | 23 | For example: `next`, `next@latest`, or `next@15.0.0-rc.1` 24 | 25 | ## Returns 26 | 27 | `Promise`\<`string`[]\> 28 | -------------------------------------------------------------------------------- /docs/test/util/functions/gitRepositoryFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / gitRepositoryFixture 6 | 7 | # Function: gitRepositoryFixture() 8 | 9 | > **gitRepositoryFixture**(): [`GitRepositoryFixture`](../type-aliases/GitRepositoryFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/git-repository.d.ts:53 12 | 13 | This fixture initializes the dummy root directory as a git repository. 14 | 15 | ## Returns 16 | 17 | [`GitRepositoryFixture`](../type-aliases/GitRepositoryFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/functions/isMockedExitError.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / isMockedExitError 6 | 7 | # Function: isMockedExitError() 8 | 9 | > **isMockedExitError**(`parameter`): `parameter is MockedExitError` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:2 12 | 13 | ## Parameters 14 | 15 | ### parameter 16 | 17 | `unknown` 18 | 19 | ## Returns 20 | 21 | `parameter is MockedExitError` 22 | -------------------------------------------------------------------------------- /docs/test/util/functions/isolatedImport.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / isolatedImport 6 | 7 | # Function: isolatedImport() 8 | 9 | > **isolatedImport**\<`Module`\>(`specifier`, `options`?): `Module` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-import/dist/packages/test-mock-import/src/index.d.ts:34 12 | 13 | Performs a CJS module import (via `require`) as if it were being imported for 14 | the first time. 15 | 16 | Note that this function breaks the "require caching" expectation of Node.js 17 | modules. Problems can arise, for example, when closing an app-wide database 18 | connection in your test cleanup phase and expecting it to close for the 19 | isolated module too. In this case, the isolated module has its own isolated 20 | "app-wide" connection that would not actually be closed and could cause your 21 | test to hang unexpectedly, even when all tests pass. 22 | 23 | ## Type Parameters 24 | 25 | ### Module 26 | 27 | `Module` 28 | 29 | ## Parameters 30 | 31 | ### specifier 32 | 33 | Specifier or absolute path to the module under test. Module resolution is 34 | handled by `require`, therefore the specifier, if a filesystem path, should 35 | never be relative and must always use unix-style separators (i.e. `/`). 36 | 37 | `string` | `AbsolutePath` 38 | 39 | ### options? 40 | 41 | [`IsolatedImportOptions`](../type-aliases/IsolatedImportOptions.md) 42 | 43 | ## Returns 44 | 45 | `Module` 46 | -------------------------------------------------------------------------------- /docs/test/util/functions/mockArgvFactory.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / mockArgvFactory 6 | 7 | # Function: mockArgvFactory() 8 | 9 | > **mockArgvFactory**(`factorySimulatedArgv`, `factoryOptions`?): (`test`, `simulatedArgv`?, `options`?) => `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-argv/dist/packages/test-mock-argv/src/index.d.ts:32 12 | 13 | Return a function that, when invoked, returns a pre-configured 14 | [withMockedArgv](withMockedArgv.md) function. 15 | 16 | This is useful for centralizing mock configuration in one place instead of 17 | duplicating configuration across [withMockedArgv](withMockedArgv.md) calls. 18 | 19 | ## Parameters 20 | 21 | ### factorySimulatedArgv 22 | 23 | `string`[] 24 | 25 | ### factoryOptions? 26 | 27 | [`MockedArgvOptions`](../type-aliases/MockedArgvOptions.md) 28 | 29 | ## Returns 30 | 31 | `Function` 32 | 33 | ### Parameters 34 | 35 | #### test 36 | 37 | () => `Promisable`\<`void`\> 38 | 39 | #### simulatedArgv? 40 | 41 | `string`[] 42 | 43 | #### options? 44 | 45 | [`MockedArgvOptions`](../type-aliases/MockedArgvOptions.md) 46 | 47 | ### Returns 48 | 49 | `Promise`\<`void`\> 50 | -------------------------------------------------------------------------------- /docs/test/util/functions/mockEnvFactory.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / mockEnvFactory 6 | 7 | # Function: mockEnvFactory() 8 | 9 | > **mockEnvFactory**(`factorySimulatedEnv`, `factoryOptions`?): (`test`, `simulatedEnv`?, `options`?) => `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-env/dist/packages/test-mock-env/src/index.d.ts:51 12 | 13 | Return a function that, when invoked, returns a pre-configured 14 | [withMockedEnv](withMockedEnv.md) function. 15 | 16 | This is useful for centralizing mock configuration in one place instead of 17 | duplicating configuration across [withMockedEnv](withMockedEnv.md) calls. 18 | 19 | ## Parameters 20 | 21 | ### factorySimulatedEnv 22 | 23 | `Record`\<`string`, `string`\> 24 | 25 | ### factoryOptions? 26 | 27 | [`MockedEnvOptions`](../type-aliases/MockedEnvOptions.md) 28 | 29 | ## Returns 30 | 31 | `Function` 32 | 33 | ### Parameters 34 | 35 | #### test 36 | 37 | () => `Promisable`\<`void`\> 38 | 39 | #### simulatedEnv? 40 | 41 | `Record`\<`string`, `string`\> 42 | 43 | #### options? 44 | 45 | [`MockedEnvOptions`](../type-aliases/MockedEnvOptions.md) 46 | 47 | ### Returns 48 | 49 | `Promise`\<`void`\> 50 | -------------------------------------------------------------------------------- /docs/test/util/functions/nodeImportAndRunTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / nodeImportAndRunTestFixture 6 | 7 | # Function: nodeImportAndRunTestFixture() 8 | 9 | > **nodeImportAndRunTestFixture**(): [`NodeImportAndRunTestFixture`](../type-aliases/NodeImportAndRunTestFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/node-import-and-run-test.d.ts:81 12 | 13 | This fixture initializes the dummy root directory with an index file under 14 | `src` (described by `initialVirtualFiles`) and then executes it using node 15 | (by default). It is expected that this file imports and tests the package 16 | under test. 17 | 18 | The index file must have a path matching the pattern `src/index${extension}` 19 | or `src/index.test${extension}`; it can have any of the following extensions: 20 | `.js`, `.cjs`, `.mjs`, `.jsx`, `.ts`, `.cts`, `.mts`, `.tsx`. 21 | 22 | ## Returns 23 | 24 | [`NodeImportAndRunTestFixture`](../type-aliases/NodeImportAndRunTestFixture.md) 25 | -------------------------------------------------------------------------------- /docs/test/util/functions/npmCopyPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / npmCopyPackageFixture 6 | 7 | # Function: npmCopyPackageFixture() 8 | 9 | > **npmCopyPackageFixture**(): [`NpmCopyPackageFixture`](../type-aliases/NpmCopyPackageFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-copy-package.d.ts:116 12 | 13 | This fixture is similar to `npmLinkPackage` except it copies all of the 14 | distributables, identified by the package under test's `package.json` `files` 15 | field, into the dummy `node_modules` directory created by a fixture like 16 | `dummyNpmPackage`. 17 | 18 | Also unlike `npmLinkPackage`, this fixture will install all of the package 19 | under test's dependencies (with respect to 20 | [NpmCopyPackageFixtureOptions.ignorePackageDependencies](../type-aliases/NpmCopyPackageFixtureOptions.md)) into the 21 | dummy `node_modules` as well. 22 | 23 | This fixture should be preferred over `npmLinkPackage` **only if the package 24 | under test does _not_ have peer dependencies.** If said package _does_ have 25 | peer dependencies, then using this fixture could manifest something akin to 26 | the dual package hazard. 27 | 28 | ## Returns 29 | 30 | [`NpmCopyPackageFixture`](../type-aliases/NpmCopyPackageFixture.md) 31 | -------------------------------------------------------------------------------- /docs/test/util/functions/npmLinkPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / npmLinkPackageFixture 6 | 7 | # Function: npmLinkPackageFixture() 8 | 9 | > **npmLinkPackageFixture**(): [`NpmLinkPackageFixture`](../type-aliases/NpmLinkPackageFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-link-package.d.ts:57 12 | 13 | This fixture is similar to `npmCopyPackage` except it makes a symbolic link 14 | (soft link) in the dummy root directory's `node_modules` subdirectory 15 | pointing to the package under test's `dist/` directory (which is typically 16 | created by `dummyNpmPackage`). 17 | 18 | It is also very similar to the `npm link` command but without any of the 19 | baggage. 20 | 21 | **This fixture should be preferred over `npmCopyPackage` whenever the package 22 | under test has peer dependencies.** Using `npmCopyPackage` with a package 23 | that has peer dependencies could manifest something akin to the dual package 24 | hazard. 25 | 26 | ## Returns 27 | 28 | [`NpmLinkPackageFixture`](../type-aliases/NpmLinkPackageFixture.md) 29 | -------------------------------------------------------------------------------- /docs/test/util/functions/protectedImportFactory.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / protectedImportFactory 6 | 7 | # Function: protectedImportFactory() 8 | 9 | > **protectedImportFactory**\<`Module`\>(...`__namedParameters`): \<`LocalModule`\>(`__namedParameters`?) => `Promise`\<`LocalModule`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-import/dist/packages/test-mock-import/src/index.d.ts:52 12 | 13 | Returns a function that, when invoked, performs a CJS module import (via 14 | `require`) as if it were being imported for the first time. Also awaits the 15 | import result and protects the caller from any calls to `process.exit` from 16 | the imported module. 17 | 18 | Use `expectedExitCode` when the import is expected to terminate with a 19 | specific exit code. 20 | 21 | ## Type Parameters 22 | 23 | ### Module 24 | 25 | `Module` 26 | 27 | ## Parameters 28 | 29 | ### \_\_namedParameters 30 | 31 | ...\[`string` \| `AbsolutePath`, [`IsolatedImportOptions`](../type-aliases/IsolatedImportOptions.md)\] 32 | 33 | ## Returns 34 | 35 | `Function` 36 | 37 | ### Type Parameters 38 | 39 | #### LocalModule 40 | 41 | `LocalModule` = `Module` 42 | 43 | ### Parameters 44 | 45 | #### \_\_namedParameters? 46 | 47 | [`IsolatedImportOptions`](../type-aliases/IsolatedImportOptions.md) & `object` 48 | 49 | ### Returns 50 | 51 | `Promise`\<`LocalModule`\> 52 | 53 | ## See 54 | 55 | [isolatedImport](isolatedImport.md) 56 | -------------------------------------------------------------------------------- /docs/test/util/functions/reconfigureJestGlobalsToSkipTestsInThisFileIfRequested.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / reconfigureJestGlobalsToSkipTestsInThisFileIfRequested 6 | 7 | # Function: reconfigureJestGlobalsToSkipTestsInThisFileIfRequested() 8 | 9 | > **reconfigureJestGlobalsToSkipTestsInThisFileIfRequested**(`targets`?): `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:141 12 | 13 | This function replaces Jest's `describe`, `test`, and `it` functions in the 14 | current file with `describe.skip`, `test.skip`, and `it.skip` if 15 | `process.env.SYMBIOTE_TEST_JEST_SKIP_SLOW_TESTS >= 1`. The replaced functions 16 | also have a `noskip` method which are aliases for their respective original 17 | versions. 18 | 19 | Essentially, this function changes Jest's execution semantics such that all 20 | tests in a given file are skipped by default. Use the `noskip` method to opt 21 | a test into always being run. 22 | 23 | To prevent a file from being executed in its entirety (for example, a test 24 | file with hundreds or thousands of tests that still take a noticeable amount 25 | of time to skip), include the string `-slow.` in the file's name, e.g. 26 | `unit-my-slow.test.ts`, and set 27 | `process.env.SYMBIOTE_TEST_JEST_SKIP_SLOW_TESTS >= 2`. 28 | 29 | See the [symbiote wiki](https://github.com/Xunnamius/symbiote/wiki) for more 30 | details. 31 | 32 | ## Parameters 33 | 34 | ### targets? 35 | 36 | Determines which Jest globals are targeted for reconfiguration. 37 | 38 | By default, only `describe` is reconfigured while `test` and `it` are left 39 | alone. This makes it easier to apply `noskip` to a collection of tests, but 40 | sometimes it's prudent to reconfigure the other globals as well. 41 | 42 | #### describe? 43 | 44 | `boolean` 45 | 46 | **Default** 47 | 48 | ```ts 49 | true 50 | ``` 51 | 52 | #### it? 53 | 54 | `boolean` 55 | 56 | **Default** 57 | 58 | ```ts 59 | false 60 | ``` 61 | 62 | #### test? 63 | 64 | `boolean` 65 | 66 | **Default** 67 | 68 | ```ts 69 | false 70 | ``` 71 | 72 | ## Returns 73 | 74 | `object` 75 | 76 | ### describe 77 | 78 | > **describe**: `Describe` 79 | 80 | ### it 81 | 82 | > **it**: `It` 83 | 84 | ### test 85 | 86 | > **test**: `It` 87 | -------------------------------------------------------------------------------- /docs/test/util/functions/rootFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / rootFixture 6 | 7 | # Function: rootFixture() 8 | 9 | > **rootFixture**(): [`RootFixture`](../type-aliases/RootFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/root.d.ts:20 12 | 13 | This fixture creates the dummy root directory as well as the `src/` 14 | subdirectory. It is perhaps the most important fixture. 15 | 16 | If the first fixture in the array of fixtures passed to the `fixtures` 17 | parameter of `withMockedFixtures` is not this fixture, then this fixture is 18 | prepended to `fixtures`. 19 | 20 | If this fixture appears anywhere else in `fixtures` other than as the first 21 | element, it will be ignored entirely. 22 | 23 | ## Returns 24 | 25 | [`RootFixture`](../type-aliases/RootFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/functions/runTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / runTestFixture 6 | 7 | # Function: runTestFixture() 8 | 9 | > **runTestFixture**(): [`RunTestFixture`](../type-aliases/RunTestFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/run-test.d.ts:68 12 | 13 | This fixture executes a binary with the specified arguments. 14 | 15 | ## Returns 16 | 17 | [`RunTestFixture`](../type-aliases/RunTestFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/functions/webpackTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / webpackTestFixture 6 | 7 | # Function: webpackTestFixture() 8 | 9 | > **webpackTestFixture**(): [`WebpackTestFixture`](../type-aliases/WebpackTestFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/webpack-test.d.ts:66 12 | 13 | This fixture initializes the dummy root directory with an index file under 14 | `src` and an optional `webpack.config.mjs` file (both described by 15 | `initialVirtualFiles`), executes Webpack, and then attempts to run the 16 | resultant file (described by `fileUnderTest`) using Node.js. 17 | 18 | Node.js is invoked with the `FORCE_COLOR=false`, `NO_COLOR=true`, and 19 | `DEBUG_COLORS=false` environment variables (among other options) as well as 20 | the `--no-warnings`, `--experimental-json-modules`, and 21 | `--experimental-vm-modules` flags. 22 | 23 | The index file must have a path matching the pattern `src/index${extension}`; 24 | it can have any of the following extensions: `.js`, `.cjs`, `.mjs`, `.jsx`, 25 | `.ts`, `.cts`, `.mts`, `.tsx`. 26 | 27 | ## Returns 28 | 29 | [`WebpackTestFixture`](../type-aliases/WebpackTestFixture.md) 30 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMockedArgv.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMockedArgv 6 | 7 | # Function: withMockedArgv() 8 | 9 | > **withMockedArgv**(`test`, `simulatedArgv`, `__namedParameters`?): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-argv/dist/packages/test-mock-argv/src/index.d.ts:22 12 | 13 | Mock `process.argv` within the scope of `test`. Guaranteed to return 14 | `process.argv` to its original state no matter how `test` terminates. 15 | 16 | **WARNING: it is not safe to run this function concurrently (e.g. with 17 | `Promise.all`).** 18 | 19 | ## Parameters 20 | 21 | ### test 22 | 23 | () => `Promisable`\<`void`\> 24 | 25 | ### simulatedArgv 26 | 27 | `string`[] 28 | 29 | ### \_\_namedParameters? 30 | 31 | [`MockedArgvOptions`](../type-aliases/MockedArgvOptions.md) 32 | 33 | ## Returns 34 | 35 | `Promise`\<`void`\> 36 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMockedEnv.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMockedEnv 6 | 7 | # Function: withMockedEnv() 8 | 9 | > **withMockedEnv**(`test`, `simulatedEnv`, `__namedParameters`?): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-env/dist/packages/test-mock-env/src/index.d.ts:40 12 | 13 | Mock `process.env` within the scope of `test`. Guaranteed to return 14 | `process.env` to its original state no matter how `test` terminates. 15 | 16 | **WARNING: it is not safe to run this function concurrently (e.g. with 17 | `Promise.all`).** 18 | 19 | ## Parameters 20 | 21 | ### test 22 | 23 | () => `Promisable`\<`void`\> 24 | 25 | ### simulatedEnv 26 | 27 | `Record`\<`string`, `string`\> 28 | 29 | ### \_\_namedParameters? 30 | 31 | [`MockedEnvOptions`](../type-aliases/MockedEnvOptions.md) 32 | 33 | ## Returns 34 | 35 | `Promise`\<`void`\> 36 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMockedExit.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMockedExit 6 | 7 | # Function: withMockedExit() 8 | 9 | > **withMockedExit**(`test`): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/index.d.ts:10 12 | 13 | Mock `process.exit` within the scope of `test`. Guaranteed to return 14 | `process.env` to its original state no matter how `test` terminates. 15 | 16 | **WARNING: it is not safe to run this function concurrently (e.g. with 17 | `Promise.all`).** 18 | 19 | ## Parameters 20 | 21 | ### test 22 | 23 | (`spies`) => `Promisable`\<`void`\> 24 | 25 | ## Returns 26 | 27 | `Promise`\<`void`\> 28 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMockedFixtures.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMockedFixtures 6 | 7 | # Function: withMockedFixtures() 8 | 9 | > **withMockedFixtures**\<`Fixtures`, `AdditionalOptions`, `AdditionalContext`\>(`test`, `fixtures`, `options`): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/index.d.ts:25 12 | 13 | Create a mock or "dummy" filesystem structure used to simulate one or more 14 | runtime environments for the package under test. 15 | 16 | When passing one-off custom fixture functions via the `fixtures` parameter, 17 | use the `AdditionalOptions` and `AdditionalContext` type parameters to supply 18 | any additional options and context where necessary. 19 | 20 | ## Type Parameters 21 | 22 | ### Fixtures 23 | 24 | `Fixtures` *extends* [`GenericMockFixtureFunctions`](../type-aliases/GenericMockFixtureFunctions.md) 25 | 26 | ### AdditionalOptions 27 | 28 | `AdditionalOptions` *extends* `Record`\<`string`, `unknown`\> = `EmptyObject` 29 | 30 | ### AdditionalContext 31 | 32 | `AdditionalContext` *extends* `Record`\<`string`, `unknown`\> = `EmptyObject` 33 | 34 | ## Parameters 35 | 36 | ### test 37 | 38 | (`context`) => `unknown` 39 | 40 | The function responsible for interfacing with the testing framework (e.g. 41 | running `expect` functions). 42 | 43 | ### fixtures 44 | 45 | `Fixtures` 46 | 47 | The fixtures used to construct the dummy environment. If the describeRoot 48 | fixture is not included, it will be appended automatically. If the root 49 | fixture is not included, it will be prepended automatically; if it is 50 | included but not the first element, said instance(s) will be removed. 51 | 52 | Otherwise, **duplicate fixtures are _not_ filtered out!** 53 | 54 | ### options 55 | 56 | `ReadonlyDeep`\<[`GlobalFixtureOptions`](../type-aliases/GlobalFixtureOptions.md) & [`GenericMockFixture`](../type-aliases/GenericMockFixture.md) *extends* `ReturnType`\<`Fixtures`\[`number`\]\> ? `unknown` : `IfAny`\<`ReturnType`\<`Fixtures`\[`number`\]\>, `unknown`, `ReturnVIfTExtendsU`\<[`DescribeRootFixture`](../type-aliases/DescribeRootFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`DescribeRootFixtureOptions`](../type-aliases/DescribeRootFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`DummyDirectoriesFixture`](../type-aliases/DummyDirectoriesFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`DummyDirectoriesFixtureOptions`](../type-aliases/DummyDirectoriesFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`DummyFilesFixture`](../type-aliases/DummyFilesFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`DummyFilesFixtureOptions`](../type-aliases/DummyFilesFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`DummyNpmPackageFixture`](../type-aliases/DummyNpmPackageFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`DummyNpmPackageFixtureOptions`](../type-aliases/DummyNpmPackageFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`GitRepositoryFixture`](../type-aliases/GitRepositoryFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`GitRepositoryFixtureOptions`](../type-aliases/GitRepositoryFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`NodeImportAndRunTestFixture`](../type-aliases/NodeImportAndRunTestFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`NodeImportAndRunTestFixtureOptions`](../type-aliases/NodeImportAndRunTestFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`RunTestFixture`](../type-aliases/RunTestFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`RunTestFixtureOptions`](../type-aliases/RunTestFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`NpmCopyPackageFixture`](../type-aliases/NpmCopyPackageFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`NpmCopyPackageFixtureOptions`](../type-aliases/NpmCopyPackageFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`NpmLinkPackageFixture`](../type-aliases/NpmLinkPackageFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`NpmLinkPackageFixtureOptions`](../type-aliases/NpmLinkPackageFixtureOptions.md), `true`\> & `ReturnVIfTExtendsU`\<[`WebpackTestFixture`](../type-aliases/WebpackTestFixture.md), `ReturnType`\<`Fixtures`\[`number`\]\>, [`WebpackTestFixtureOptions`](../type-aliases/WebpackTestFixtureOptions.md), `true`\>\> & `NoInfer`\<`AdditionalOptions`\>\> 57 | 58 | Options seen by all fixtures. 59 | 60 | ## Returns 61 | 62 | `Promise`\<`void`\> 63 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMockedOutput.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMockedOutput 6 | 7 | # Function: withMockedOutput() 8 | 9 | > **withMockedOutput**(`test`, `__namedParameters`?): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:76 12 | 13 | Mock terminal output functions within the scope of `test`. Guaranteed to 14 | return terminal output functions to their original state no matter how `test` 15 | terminates. 16 | 17 | **WARNING: it is not safe to run this function concurrently (e.g. with 18 | `Promise.all`).** 19 | 20 | ## Parameters 21 | 22 | ### test 23 | 24 | (`spies`) => `unknown` 25 | 26 | ### \_\_namedParameters? 27 | 28 | [`MockedOutputOptions`](../type-aliases/MockedOutputOptions.md) 29 | 30 | ## Returns 31 | 32 | `Promise`\<`void`\> 33 | -------------------------------------------------------------------------------- /docs/test/util/functions/withMocks.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / withMocks 6 | 7 | # Function: withMocks() 8 | 9 | > **withMocks**(`fn`, `__namedParameters`?): `Promise`\<`void`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/jest/dist/packages/jest/src/index.d.ts:171 12 | 13 | Wraps [withMockedArgv](withMockedArgv.md) + [withMockedEnv](withMockedEnv.md) with 14 | [withMockedExit](withMockedExit.md) + [withMockedOutput](withMockedOutput.md). 15 | 16 | ## Parameters 17 | 18 | ### fn 19 | 20 | (`spies`) => `Promise`\<`void`\> 21 | 22 | ### \_\_namedParameters? 23 | 24 | #### options? 25 | 26 | \{ `passthrough`: (`"log"` \| `"error"` \| `"warn"` \| `"info"` \| `"stdout"` \| `"stderr"`)[]; `passthroughDebugEnv`: `boolean`; `passthroughOutputIfDebugging`: `boolean`; `replaceEntireArgv`: `boolean`; `replaceEntireEnv`: `boolean`; \} 27 | 28 | #### options.passthrough? 29 | 30 | (`"log"` \| `"error"` \| `"warn"` \| `"info"` \| `"stdout"` \| `"stderr"`)[] 31 | 32 | Prevent mocking the implementation of one or more output spies, allowing 33 | output to be passed through to the original function. Said spies will 34 | remain functional. 35 | 36 | **Default** 37 | 38 | ```ts 39 | [] 40 | ``` 41 | 42 | #### options.passthroughDebugEnv? 43 | 44 | `boolean` 45 | 46 | If `true`, whenever `process.env.DEBUG` is present, it will be forwarded 47 | as-is to the underlying environment mock even when `replaceEntireEnv` is 48 | `true`. This allows debug output to make it to the screen. 49 | 50 | **Default** 51 | 52 | ```ts 53 | true 54 | ``` 55 | 56 | #### options.passthroughOutputIfDebugging? 57 | 58 | `boolean` 59 | 60 | If `true`, whenever `process.env.DEBUG` is present, output functions will 61 | still be spied on but their implementations will not be mocked, allowing 62 | debug output to make it to the screen. 63 | 64 | **Default** 65 | 66 | ```ts 67 | true 68 | ``` 69 | 70 | #### options.replaceEntireArgv? 71 | 72 | `boolean` 73 | 74 | By default, the first two elements in `process.argv` are preserved. Setting 75 | `replace` to `true` will cause the entire process.argv array to be 76 | replaced. 77 | 78 | **Default** 79 | 80 | ```ts 81 | false 82 | ``` 83 | 84 | #### options.replaceEntireEnv? 85 | 86 | `boolean` 87 | 88 | By default, all environment variables in the `process.env` object are 89 | deleted before the object is re-hydrated with `newEnv`. 90 | 91 | Two environment variables, if present, are exempt from deletion: 92 | `process.env.DEBUG` and `process.env.DEBUG_COLORS`. 93 | 94 | Setting `replace` to `false` will cause `newEnv` to be merged on top of 95 | `process.env` instead of replacing it. Setting `replace` to `true` will 96 | cause `newEnv` to replace the _entire_ `process.env` object, including 97 | `process.env.DEBUG_COLORS`. 98 | 99 | Note that `process.env.DEBUG` is unaffected by this option (see 100 | [MockedEnvOptions.passthroughDebugEnv](../type-aliases/MockedEnvOptions.md#passthroughdebugenv) instead). 101 | 102 | **Default** 103 | 104 | ```ts 105 | undefined 106 | ``` 107 | 108 | #### simulatedArgv? 109 | 110 | `string`[] 111 | 112 | #### simulatedEnv? 113 | 114 | `Record`\<`string`, `string`\> 115 | 116 | ## Returns 117 | 118 | `Promise`\<`void`\> 119 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/AsDefault.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / AsDefault 6 | 7 | # Type Alias: AsDefault\ 8 | 9 | > **AsDefault**\<`T`\> = `T` *extends* `object` ? `T`\[`"default"`\] : `T` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-import/dist/packages/test-mock-import/src/index.d.ts:6 12 | 13 | A helper type that reduces an object type to its `default` property, if such 14 | a property exists, or returns it as-is if it does not. 15 | 16 | ## Type Parameters 17 | 18 | ### T 19 | 20 | `T` 21 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DescribeRootFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DescribeRootFixture 6 | 7 | # Type Alias: DescribeRootFixture 8 | 9 | > **DescribeRootFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`describeRootFixtureName`](../variables/describeRootFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`DescribeRootFixtureOptions`](DescribeRootFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/describe-root.d.ts:9 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [describeRootFixture](../functions/describeRootFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DescribeRootFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DescribeRootFixtureContext 6 | 7 | # Type Alias: DescribeRootFixtureContext 8 | 9 | > **DescribeRootFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`describeRootFixtureName`](../variables/describeRootFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/describe-root.d.ts:33 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [describeRootFixture](../functions/describeRootFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DescribeRootFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DescribeRootFixtureOptions 6 | 7 | # Type Alias: DescribeRootFixtureOptions 8 | 9 | > **DescribeRootFixtureOptions** = `Tagged`\<`EmptyObject`, *typeof* [`describeRootFixtureName`](../variables/describeRootFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/describe-root.d.ts:19 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [describeRootFixture](../functions/describeRootFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyDirectoriesFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyDirectoriesFixture 6 | 7 | # Type Alias: DummyDirectoriesFixture 8 | 9 | > **DummyDirectoriesFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`dummyDirectoriesFixtureName`](../variables/dummyDirectoriesFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`DummyDirectoriesFixtureOptions`](DummyDirectoriesFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-directories.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [dummyDirectoriesFixture](../functions/dummyDirectoriesFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyDirectoriesFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyDirectoriesFixtureContext 6 | 7 | # Type Alias: DummyDirectoriesFixtureContext 8 | 9 | > **DummyDirectoriesFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`dummyDirectoriesFixtureName`](../variables/dummyDirectoriesFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-directories.d.ts:40 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [dummyDirectoriesFixture](../functions/dummyDirectoriesFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyDirectoriesFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyDirectoriesFixtureOptions 6 | 7 | # Type Alias: DummyDirectoriesFixtureOptions 8 | 9 | > **DummyDirectoriesFixtureOptions** = `Tagged`\<\{ `directoryPaths`: `RelativePath`[]; \}, *typeof* [`dummyDirectoriesFixtureName`](../variables/dummyDirectoriesFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-directories.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [dummyDirectoriesFixture](../functions/dummyDirectoriesFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyFilesFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyFilesFixture 6 | 7 | # Type Alias: DummyFilesFixture 8 | 9 | > **DummyFilesFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`dummyFilesFixtureName`](../variables/dummyFilesFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`DummyFilesFixtureOptions`](DummyFilesFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-files.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [dummyFilesFixture](../functions/dummyFilesFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyFilesFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyFilesFixtureContext 6 | 7 | # Type Alias: DummyFilesFixtureContext 8 | 9 | > **DummyFilesFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`dummyFilesFixtureName`](../variables/dummyFilesFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-files.d.ts:42 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [dummyFilesFixture](../functions/dummyFilesFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyFilesFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyFilesFixtureOptions 6 | 7 | # Type Alias: DummyFilesFixtureOptions 8 | 9 | > **DummyFilesFixtureOptions** = `Tagged`\<`Required`\<`Pick`\<[`GlobalFixtureOptions`](GlobalFixtureOptions.md), `"initialVirtualFiles"`\>\> & `object`, *typeof* [`dummyFilesFixtureName`](../variables/dummyFilesFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-files.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [dummyFilesFixture](../functions/dummyFilesFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyNpmPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyNpmPackageFixture 6 | 7 | # Type Alias: DummyNpmPackageFixture 8 | 9 | > **DummyNpmPackageFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`dummyNpmPackageFixtureName`](../variables/dummyNpmPackageFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`DummyNpmPackageFixtureOptions`](DummyNpmPackageFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-npm-package.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [dummyNpmPackageFixture](../functions/dummyNpmPackageFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyNpmPackageFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyNpmPackageFixtureContext 6 | 7 | # Type Alias: DummyNpmPackageFixtureContext 8 | 9 | > **DummyNpmPackageFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`dummyNpmPackageFixtureName`](../variables/dummyNpmPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-npm-package.d.ts:59 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [dummyNpmPackageFixture](../functions/dummyNpmPackageFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/DummyNpmPackageFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / DummyNpmPackageFixtureOptions 6 | 7 | # Type Alias: DummyNpmPackageFixtureOptions 8 | 9 | > **DummyNpmPackageFixtureOptions** = `Tagged`\<\{ `additionalPackagesToInstall`: `string` \| `string`[]; `installCommand`: `"ci"` \| `"install"`; `packageUnderTest`: `Omit`\<`GenericPackage`, `"projectMetadata"`\>; `runInstallScripts`: `boolean`; \}, *typeof* [`dummyNpmPackageFixtureName`](../variables/dummyNpmPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-npm-package.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [dummyNpmPackageFixture](../functions/dummyNpmPackageFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/FixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / FixtureContext 6 | 7 | # Type Alias: FixtureContext\ 8 | 9 | > **FixtureContext**\<`Options`\> = `object` & `ReturnVIfTExtendsU`\<`Options`, [`DescribeRootFixtureOptions`](DescribeRootFixtureOptions.md), [`DescribeRootFixtureContext`](DescribeRootFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`DummyDirectoriesFixtureOptions`](DummyDirectoriesFixtureOptions.md), [`DummyDirectoriesFixtureContext`](DummyDirectoriesFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`DummyFilesFixtureOptions`](DummyFilesFixtureOptions.md), [`DummyFilesFixtureContext`](DummyFilesFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`DummyNpmPackageFixtureOptions`](DummyNpmPackageFixtureOptions.md), [`DummyNpmPackageFixtureContext`](DummyNpmPackageFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`GitRepositoryFixtureOptions`](GitRepositoryFixtureOptions.md), [`GitRepositoryFixtureContext`](GitRepositoryFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`NodeImportAndRunTestFixtureOptions`](NodeImportAndRunTestFixtureOptions.md), [`NodeImportAndRunTestFixtureContext`](NodeImportAndRunTestFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`RunTestFixtureOptions`](RunTestFixtureOptions.md), [`RunTestFixtureContext`](RunTestFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`NpmCopyPackageFixtureOptions`](NpmCopyPackageFixtureOptions.md), [`NpmCopyPackageFixtureContext`](NpmCopyPackageFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`NpmLinkPackageFixtureOptions`](NpmLinkPackageFixtureOptions.md), [`NpmLinkPackageFixtureContext`](NpmLinkPackageFixtureContext.md)\> & `ReturnVIfTExtendsU`\<`Options`, [`WebpackTestFixtureOptions`](WebpackTestFixtureOptions.md), [`WebpackTestFixtureContext`](WebpackTestFixtureContext.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:64 12 | 13 | The context object passed around between every [MockFixture](MockFixture.md). 14 | 15 | ## Type declaration 16 | 17 | ### debug 18 | 19 | > **debug**: `ExtendedDebugger` 20 | 21 | An ExtendedDebugger instance extended specifically for use by the 22 | current fixture. 23 | 24 | ### fixtures 25 | 26 | > **fixtures**: [`GenericMockFixture`](GenericMockFixture.md)[] 27 | 28 | The fixtures that comprise the current runtime. 29 | 30 | ### fs 31 | 32 | > **fs**: [`FixtureFs`](FixtureFs.md) 33 | 34 | Context-sensitive asynchronous wrappers for `node:fs/promises` functions 35 | (excluding FixtureFs.glob) with in-built debugging and exception 36 | handling. 37 | 38 | Note that all relative `PathLike` parameters are considered local to 39 | `root`, not the current working directory, and will be translated into 40 | AbsolutePaths as such. 41 | 42 | ### options 43 | 44 | > **options**: `ReadonlyDeep`\<[`GlobalFixtureOptions`](GlobalFixtureOptions.md)\> & `ReadonlyDeep`\<`Omit`\<`Options` *extends* `Tagged`\<`unknown`, `PropertyKey`\> ? `UnwrapTagged`\<`Options`\> : `Options`, *typeof* `emptyObjectSymbol`\>\> 45 | 46 | The options applicable to the current runtime. 47 | 48 | ### root 49 | 50 | > **root**: `AbsolutePath` 51 | 52 | The AbsolutePath pointing to the dummy root directory. 53 | 54 | ### virtualFiles 55 | 56 | > **virtualFiles**: `object` 57 | 58 | The mutable "virtual files" as they exist currently in memory, including 59 | any mutations performed by fixtures. 60 | 61 | #### Index Signature 62 | 63 | \[`filePath`: `RelativePath`\]: `string` 64 | 65 | #### See 66 | 67 | [GlobalFixtureOptions.initialVirtualFiles](GlobalFixtureOptions.md#initialvirtualfiles) 68 | 69 | ## Type Parameters 70 | 71 | ### Options 72 | 73 | `Options` 74 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/FixtureFs.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / FixtureFs 6 | 7 | # Type Alias: FixtureFs 8 | 9 | > **FixtureFs** = `object` & `Omit`\<*typeof* `fs`, `"constants"` \| `"glob"`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:126 12 | 13 | Context-sensitive asynchronous wrappers for `node:fs/promises` functions 14 | (excluding fs.glob) with in-build debugging and exception handling. 15 | 16 | Note that all relative `PathLike` parameters are considered local to `root`, 17 | not the current working directory, and will be translated into 18 | AbsolutePaths as such. 19 | 20 | ## Type declaration 21 | 22 | ### isAccessible() 23 | 24 | > **isAccessible**: (...`args`) => `Promise`\<`boolean`\> 25 | 26 | Identical to fs.access except it returns a boolean indicating 27 | accessibility. 28 | 29 | #### Parameters 30 | 31 | ##### args 32 | 33 | ...`Parameters`\<*typeof* `fs.access`\> 34 | 35 | #### Returns 36 | 37 | `Promise`\<`boolean`\> 38 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/FixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / FixtureOptions 6 | 7 | # Type Alias: FixtureOptions\ 8 | 9 | > **FixtureOptions**\<`MockFixture`, `ShouldUnwrap`\> = [`GlobalFixtureOptions`](GlobalFixtureOptions.md) & [`GenericMockFixture`](GenericMockFixture.md) *extends* `MockFixture` ? `unknown` : `IfAny`\<`MockFixture`, `unknown`, `ReturnVIfTExtendsU`\<[`DescribeRootFixture`](DescribeRootFixture.md), `MockFixture`, [`DescribeRootFixtureOptions`](DescribeRootFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`DummyDirectoriesFixture`](DummyDirectoriesFixture.md), `MockFixture`, [`DummyDirectoriesFixtureOptions`](DummyDirectoriesFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`DummyFilesFixture`](DummyFilesFixture.md), `MockFixture`, [`DummyFilesFixtureOptions`](DummyFilesFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`DummyNpmPackageFixture`](DummyNpmPackageFixture.md), `MockFixture`, [`DummyNpmPackageFixtureOptions`](DummyNpmPackageFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`GitRepositoryFixture`](GitRepositoryFixture.md), `MockFixture`, [`GitRepositoryFixtureOptions`](GitRepositoryFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`NodeImportAndRunTestFixture`](NodeImportAndRunTestFixture.md), `MockFixture`, [`NodeImportAndRunTestFixtureOptions`](NodeImportAndRunTestFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`RunTestFixture`](RunTestFixture.md), `MockFixture`, [`RunTestFixtureOptions`](RunTestFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`NpmCopyPackageFixture`](NpmCopyPackageFixture.md), `MockFixture`, [`NpmCopyPackageFixtureOptions`](NpmCopyPackageFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`NpmLinkPackageFixture`](NpmLinkPackageFixture.md), `MockFixture`, [`NpmLinkPackageFixtureOptions`](NpmLinkPackageFixtureOptions.md), `ShouldUnwrap`\> & `ReturnVIfTExtendsU`\<[`WebpackTestFixture`](WebpackTestFixture.md), `MockFixture`, [`WebpackTestFixtureOptions`](WebpackTestFixtureOptions.md), `ShouldUnwrap`\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/options.d.ts:67 12 | 13 | This type combines all possible configurable options conditioned on which 14 | fixtures are actually used. 15 | 16 | Pass `unknown` to return a generic result. 17 | 18 | ## Type Parameters 19 | 20 | ### MockFixture 21 | 22 | `MockFixture` 23 | 24 | ### ShouldUnwrap 25 | 26 | `ShouldUnwrap` *extends* `boolean` = `true` 27 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GenericFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GenericFixtureContext 6 | 7 | # Type Alias: GenericFixtureContext 8 | 9 | > **GenericFixtureContext** = [`FixtureContext`](FixtureContext.md)\<[`GlobalFixtureOptions`](GlobalFixtureOptions.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:117 12 | 13 | ## See 14 | 15 | [FixtureContext](FixtureContext.md) 16 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GenericMockFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GenericMockFixture 6 | 7 | # Type Alias: GenericMockFixture 8 | 9 | > **GenericMockFixture** = [`MockFixture`](MockFixture.md)\<`string`, `any`\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:105 12 | 13 | ## See 14 | 15 | [MockFixture](MockFixture.md) 16 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GenericMockFixtureFunction.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GenericMockFixtureFunction 6 | 7 | # Type Alias: GenericMockFixtureFunction() 8 | 9 | > **GenericMockFixtureFunction** = (...`args`) => [`GenericMockFixture`](GenericMockFixture.md) 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:109 12 | 13 | ## Parameters 14 | 15 | ### args 16 | 17 | ...`any`[] 18 | 19 | ## Returns 20 | 21 | [`GenericMockFixture`](GenericMockFixture.md) 22 | 23 | ## See 24 | 25 | [GenericMockFixture](GenericMockFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GenericMockFixtureFunctions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GenericMockFixtureFunctions 6 | 7 | # Type Alias: GenericMockFixtureFunctions 8 | 9 | > **GenericMockFixtureFunctions** = readonly [`GenericMockFixtureFunction`](GenericMockFixtureFunction.md)[] 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:113 12 | 13 | ## See 14 | 15 | [GenericMockFixtureFunction](GenericMockFixtureFunction.md) 16 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GitRepositoryFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GitRepositoryFixture 6 | 7 | # Type Alias: GitRepositoryFixture 8 | 9 | > **GitRepositoryFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`gitRepositoryFixtureName`](../variables/gitRepositoryFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`GitRepositoryFixtureOptions`](GitRepositoryFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/git-repository.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [gitRepositoryFixture](../functions/gitRepositoryFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GitRepositoryFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GitRepositoryFixtureContext 6 | 7 | # Type Alias: GitRepositoryFixtureContext 8 | 9 | > **GitRepositoryFixtureContext** = `Tagged`\<\{ `git`: `SimpleGit`; \}, *typeof* [`gitRepositoryFixtureName`](../variables/gitRepositoryFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/git-repository.d.ts:41 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [gitRepositoryFixture](../functions/gitRepositoryFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GitRepositoryFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GitRepositoryFixtureOptions 6 | 7 | # Type Alias: GitRepositoryFixtureOptions 8 | 9 | > **GitRepositoryFixtureOptions** = `Tagged`\<\{ `setupGit`: (`git`) => `Promisable`\<`void`\>; \}, *typeof* [`gitRepositoryFixtureName`](../variables/gitRepositoryFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/git-repository.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [gitRepositoryFixture](../functions/gitRepositoryFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/GlobalFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / GlobalFixtureOptions 6 | 7 | # Type Alias: GlobalFixtureOptions 8 | 9 | > **GlobalFixtureOptions** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/options.d.ts:18 12 | 13 | The options available to every fixture. 14 | 15 | ## Properties 16 | 17 | ### identifier? 18 | 19 | > `optional` **identifier**: `string` 20 | 21 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/options.d.ts:28 22 | 23 | The identifier used in various places, including when creating the dummy 24 | root directory and when describing the test environment in output text. 25 | 26 | Must be alphanumeric, optionally including hyphens and underscores. Every 27 | other character will be replaced with a hyphen. 28 | 29 | #### Default 30 | 31 | ```ts 32 | "fixtures-test" 33 | ``` 34 | 35 | *** 36 | 37 | ### initialVirtualFiles? 38 | 39 | > `optional` **initialVirtualFiles**: `object` 40 | 41 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/options.d.ts:57 42 | 43 | An object describing "virtual files" represented by mappings between 44 | non-existent RelativePaths and their theoretical (immutable) 45 | contents. These paths are relative to the dummy root directory. 46 | 47 | Non-string contents will be stringified via `JSON.stringify(entry, 48 | undefined, 2)`. 49 | 50 | Note that some fixtures use the `initialVirtualFiles` option to lookup 51 | certain values, such as picking out keys from a virtual `package.json` 52 | file. 53 | 54 | Also note that **these virtual files are not created on the filesystem 55 | automatically!** 56 | 57 | To have the virtual files described in `initialVirtualFiles` actually 58 | written out to the filesystem (relative to the dummy root directory), you 59 | must use [dummyFilesFixture](../functions/dummyFilesFixture.md). 60 | 61 | Consider also `dummyDirectoriesFixture` for writing out directories to the 62 | filesystem using the `initialDirectories` option. 63 | 64 | #### Index Signature 65 | 66 | \[`filePath`: `string` \| `RelativePath`\]: `unknown` 67 | 68 | *** 69 | 70 | ### performCleanup 71 | 72 | > **performCleanup**: `boolean` 73 | 74 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/options.d.ts:34 75 | 76 | When `true`, the dummy root directory will be deleted after the test 77 | complete (regardless of the outcome). Set `performCleanup` to `false` to 78 | disable this behavior. 79 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/IsolatedImportOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / IsolatedImportOptions 6 | 7 | # Type Alias: IsolatedImportOptions 8 | 9 | > **IsolatedImportOptions** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-import/dist/packages/test-mock-import/src/index.d.ts:12 12 | 13 | ## See 14 | 15 | [isolatedImport](../functions/isolatedImport.md) 16 | 17 | ## Properties 18 | 19 | ### reduceToDefault? 20 | 21 | > `optional` **reduceToDefault**: `boolean` 22 | 23 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-import/dist/packages/test-mock-import/src/index.d.ts:21 24 | 25 | By default, if `module.__esModule === true` and the only other property of 26 | `module.exports` is `"default"`, then said `"default"` export will be 27 | returned instead of a module object. Use `reduceToDefault` to override this 28 | behavior in either direction. 29 | 30 | #### Default 31 | 32 | ```ts 33 | undefined 34 | ``` 35 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/MockFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockFixture 6 | 7 | # Type Alias: MockFixture\ 8 | 9 | > **MockFixture**\<`Name`, `Context`\> = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:22 12 | 13 | An object describing a mock or "dummy" filesystem structure used to simulate 14 | one or more runtime environments for the package under test. 15 | 16 | ## Type Parameters 17 | 18 | ### Name 19 | 20 | `Name` *extends* `string` 21 | 22 | ### Context 23 | 24 | `Context` 25 | 26 | ## Properties 27 | 28 | ### description 29 | 30 | > **description**: `string` 31 | 32 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:34 33 | 34 | A short string output during debugging that describes what the fixture is 35 | doing. 36 | 37 | *** 38 | 39 | ### name 40 | 41 | > **name**: `Name` \| `symbol` 42 | 43 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:29 44 | 45 | An alphanumeric (including hyphens and underscores) string used to identify 46 | the fixture. This string _should_ be unique per fixture. 47 | 48 | Including invalid characters in the fixture name will cause an error. 49 | 50 | *** 51 | 52 | ### setup()? 53 | 54 | > `optional` **setup**: (`context`) => `Promisable`\<`unknown`\> 55 | 56 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:44 57 | 58 | An optional function that is run before the `test` function is invoked. 59 | 60 | If this function throws, the error will bubble, preventing other fixtures 61 | (and their setup functions) from running. 62 | 63 | If a fixture provides neither a `setup` nor `teardown` function, it is 64 | essentially a no-op. 65 | 66 | #### Parameters 67 | 68 | ##### context 69 | 70 | `Context` 71 | 72 | #### Returns 73 | 74 | `Promisable`\<`unknown`\> 75 | 76 | *** 77 | 78 | ### teardown()? 79 | 80 | > `optional` **teardown**: (`context`) => `Promisable`\<`unknown`\> 81 | 82 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/types/fixtures.d.ts:59 83 | 84 | An optional function that is run after the `test` function completes. 85 | 86 | Note that, so long as its corresponding `setup` function completed 87 | successfully, `teardown` functions are **ALWAYS** run, even when the `test` 88 | function throws, and even when the `setup`/`teardown` functions of other 89 | fixtures throw. 90 | 91 | `teardown` functions are run in reverse order; the first `teardown` 92 | function defined by a fixture will be the last `teardown` function to run. 93 | 94 | If a fixture provides neither a `setup` nor `teardown` function, it is 95 | essentially a no-op. 96 | 97 | #### Parameters 98 | 99 | ##### context 100 | 101 | `Context` 102 | 103 | #### Returns 104 | 105 | `Promisable`\<`unknown`\> 106 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/MockedArgvOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockedArgvOptions 6 | 7 | # Type Alias: MockedArgvOptions 8 | 9 | > **MockedArgvOptions** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-argv/dist/packages/test-mock-argv/src/index.d.ts:5 12 | 13 | ## See 14 | 15 | [withMockedArgv](../functions/withMockedArgv.md) 16 | 17 | ## Properties 18 | 19 | ### replaceEntireArgv? 20 | 21 | > `optional` **replaceEntireArgv**: `boolean` 22 | 23 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-argv/dist/packages/test-mock-argv/src/index.d.ts:13 24 | 25 | By default, the first two elements in `process.argv` are preserved. Setting 26 | `replace` to `true` will cause the entire process.argv array to be 27 | replaced. 28 | 29 | #### Default 30 | 31 | ```ts 32 | false 33 | ``` 34 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/MockedEnvOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockedEnvOptions 6 | 7 | # Type Alias: MockedEnvOptions 8 | 9 | > **MockedEnvOptions** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-env/dist/packages/test-mock-env/src/index.d.ts:5 12 | 13 | ## See 14 | 15 | [withMockedEnv](../functions/withMockedEnv.md) 16 | 17 | ## Properties 18 | 19 | ### passthroughDebugEnv? 20 | 21 | > `optional` **passthroughDebugEnv**: `boolean` 22 | 23 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-env/dist/packages/test-mock-env/src/index.d.ts:31 24 | 25 | If `true`, whenever `process.env.DEBUG` is present, it will be forwarded 26 | as-is to the underlying environment mock even when `replaceEntireEnv` is 27 | `true`. This allows debug output to make it to the screen. 28 | 29 | #### Default 30 | 31 | ```ts 32 | true 33 | ``` 34 | 35 | *** 36 | 37 | ### replaceEntireEnv? 38 | 39 | > `optional` **replaceEntireEnv**: `boolean` 40 | 41 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-env/dist/packages/test-mock-env/src/index.d.ts:23 42 | 43 | By default, all environment variables in the `process.env` object are 44 | deleted before the object is re-hydrated with `newEnv`. 45 | 46 | Two environment variables, if present, are exempt from deletion: 47 | `process.env.DEBUG` and `process.env.DEBUG_COLORS`. 48 | 49 | Setting `replace` to `false` will cause `newEnv` to be merged on top of 50 | `process.env` instead of replacing it. Setting `replace` to `true` will 51 | cause `newEnv` to replace the _entire_ `process.env` object, including 52 | `process.env.DEBUG_COLORS`. 53 | 54 | Note that `process.env.DEBUG` is unaffected by this option (see 55 | [MockedEnvOptions.passthroughDebugEnv](#passthroughdebugenv) instead). 56 | 57 | #### Default 58 | 59 | ```ts 60 | undefined 61 | ``` 62 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/MockedOutputOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockedOutputOptions 6 | 7 | # Type Alias: MockedOutputOptions 8 | 9 | > **MockedOutputOptions** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:5 12 | 13 | ## See 14 | 15 | [withMockedOutput](../functions/withMockedOutput.md) 16 | 17 | ## Properties 18 | 19 | ### passthrough? 20 | 21 | > `optional` **passthrough**: (`"log"` \| `"warn"` \| `"error"` \| `"info"` \| `"stdout"` \| `"stderr"`)[] 22 | 23 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:21 24 | 25 | Prevent mocking the implementation of one or more output spies, allowing 26 | output to be passed through to the original function. Said spies will 27 | remain functional. 28 | 29 | #### Default 30 | 31 | ```ts 32 | [] 33 | ``` 34 | 35 | *** 36 | 37 | ### passthroughOutputIfDebugging? 38 | 39 | > `optional` **passthroughOutputIfDebugging**: `boolean` 40 | 41 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:13 42 | 43 | If `true`, whenever `process.env.DEBUG` is present, output functions will 44 | still be spied on but their implementations will not be mocked, allowing 45 | debug output to make it to the screen. 46 | 47 | #### Default 48 | 49 | ```ts 50 | true 51 | ``` 52 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/MockedOutputSpies.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / MockedOutputSpies 6 | 7 | # Type Alias: MockedOutputSpies 8 | 9 | > **MockedOutputSpies** = `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:26 12 | 13 | ## See 14 | 15 | [withMockedOutput](../functions/withMockedOutput.md) 16 | 17 | ## Properties 18 | 19 | ### errorSpy 20 | 21 | > **errorSpy**: `jest.SpyInstance` 22 | 23 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:38 24 | 25 | Spies on `globalThis.console.error`. 26 | 27 | *** 28 | 29 | ### infoSpy 30 | 31 | > **infoSpy**: `jest.SpyInstance` 32 | 33 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:42 34 | 35 | Spies on `globalThis.console.info`. 36 | 37 | *** 38 | 39 | ### logSpy 40 | 41 | > **logSpy**: `jest.SpyInstance` 42 | 43 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:30 44 | 45 | Spies on `globalThis.console.log`. 46 | 47 | *** 48 | 49 | ### nodeErrorSpy 50 | 51 | > **nodeErrorSpy**: `jest.SpyInstance` 52 | 53 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:54 54 | 55 | Spies on `require('node:console').error`. 56 | 57 | *** 58 | 59 | ### nodeInfoSpy 60 | 61 | > **nodeInfoSpy**: `jest.SpyInstance` 62 | 63 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:58 64 | 65 | Spies on `require('node:console').info`. 66 | 67 | *** 68 | 69 | ### nodeLogSpy 70 | 71 | > **nodeLogSpy**: `jest.SpyInstance` 72 | 73 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:46 74 | 75 | Spies on `require('node:console').log`. 76 | 77 | *** 78 | 79 | ### nodeWarnSpy 80 | 81 | > **nodeWarnSpy**: `jest.SpyInstance` 82 | 83 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:50 84 | 85 | Spies on `require('node:console').warn`. 86 | 87 | *** 88 | 89 | ### stderrSpy 90 | 91 | > **stderrSpy**: `jest.SpyInstance` 92 | 93 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:66 94 | 95 | Spies on `process.stderr.write`. 96 | 97 | *** 98 | 99 | ### stdoutSpy 100 | 101 | > **stdoutSpy**: `jest.SpyInstance` 102 | 103 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:62 104 | 105 | Spies on `process.stdout.write`. 106 | 107 | *** 108 | 109 | ### warnSpy 110 | 111 | > **warnSpy**: `jest.SpyInstance` 112 | 113 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-output/dist/packages/test-mock-output/src/index.d.ts:34 114 | 115 | Spies on `globalThis.console.warn`. 116 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NodeImportAndRunTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NodeImportAndRunTestFixture 6 | 7 | # Type Alias: NodeImportAndRunTestFixture 8 | 9 | > **NodeImportAndRunTestFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`nodeImportAndRunTestFixtureName`](../variables/nodeImportAndRunTestFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`NodeImportAndRunTestFixtureOptions`](NodeImportAndRunTestFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/node-import-and-run-test.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [nodeImportAndRunTestFixture](../functions/nodeImportAndRunTestFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NodeImportAndRunTestFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NodeImportAndRunTestFixtureContext 6 | 7 | # Type Alias: NodeImportAndRunTestFixtureContext 8 | 9 | > **NodeImportAndRunTestFixtureContext** = `Tagged`\<\{ `testResult`: `RunReturnType`\<`RunOptions`\>; \}, *typeof* [`nodeImportAndRunTestFixtureName`](../variables/nodeImportAndRunTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/node-import-and-run-test.d.ts:65 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [nodeImportAndRunTestFixture](../functions/nodeImportAndRunTestFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NodeImportAndRunTestFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NodeImportAndRunTestFixtureOptions 6 | 7 | # Type Alias: NodeImportAndRunTestFixtureOptions 8 | 9 | > **NodeImportAndRunTestFixtureOptions** = `Tagged`\<\{ `runWith`: \{ `args`: `string`[]; `binary`: `string`; `runnerOptions`: `RunOptions`; \}; \}, *typeof* [`nodeImportAndRunTestFixtureName`](../variables/nodeImportAndRunTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/node-import-and-run-test.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [nodeImportAndRunTestFixture](../functions/nodeImportAndRunTestFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmCopyPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmCopyPackageFixture 6 | 7 | # Type Alias: NpmCopyPackageFixture 8 | 9 | > **NpmCopyPackageFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`npmCopyPackageFixtureName`](../variables/npmCopyPackageFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`NpmCopyPackageFixtureOptions`](NpmCopyPackageFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-copy-package.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [npmCopyPackageFixture](../functions/npmCopyPackageFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmCopyPackageFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmCopyPackageFixtureContext 6 | 7 | # Type Alias: NpmCopyPackageFixtureContext 8 | 9 | > **NpmCopyPackageFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`npmCopyPackageFixtureName`](../variables/npmCopyPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-copy-package.d.ts:99 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [npmCopyPackageFixture](../functions/npmCopyPackageFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmCopyPackageFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmCopyPackageFixtureOptions 6 | 7 | # Type Alias: NpmCopyPackageFixtureOptions 8 | 9 | > **NpmCopyPackageFixtureOptions** = `Tagged`\<\{ `ignorePackageDependencies`: \{ `bundledDependencies`: `boolean`; `dependencies`: `boolean`; `devDependencies`: `boolean`; `optionalDependencies`: `boolean`; `peerDependencies`: `boolean`; `peerDependenciesMeta`: `boolean`; \}; `packageUnderTest`: `Omit`\<`GenericPackage`, `"projectMetadata"`\>; `runInstallScripts`: `boolean`; \}, *typeof* [`npmCopyPackageFixtureName`](../variables/npmCopyPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-copy-package.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [npmCopyPackageFixture](../functions/npmCopyPackageFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmLinkPackageFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmLinkPackageFixture 6 | 7 | # Type Alias: NpmLinkPackageFixture 8 | 9 | > **NpmLinkPackageFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`npmLinkPackageFixtureName`](../variables/npmLinkPackageFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`NpmLinkPackageFixtureOptions`](NpmLinkPackageFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-link-package.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [npmLinkPackageFixture](../functions/npmLinkPackageFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmLinkPackageFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmLinkPackageFixtureContext 6 | 7 | # Type Alias: NpmLinkPackageFixtureContext 8 | 9 | > **NpmLinkPackageFixtureContext** = `Tagged`\<`EmptyObject`, *typeof* [`npmLinkPackageFixtureName`](../variables/npmLinkPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-link-package.d.ts:42 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [npmLinkPackageFixture](../functions/npmLinkPackageFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/NpmLinkPackageFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / NpmLinkPackageFixtureOptions 6 | 7 | # Type Alias: NpmLinkPackageFixtureOptions 8 | 9 | > **NpmLinkPackageFixtureOptions** = `Tagged`\<\{ `packageUnderTest`: `Omit`\<`GenericPackage`, `"projectMetadata"`\>; \}, *typeof* [`npmLinkPackageFixtureName`](../variables/npmLinkPackageFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-link-package.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [npmLinkPackageFixture](../functions/npmLinkPackageFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/RootFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / RootFixture 6 | 7 | # Type Alias: RootFixture 8 | 9 | > **RootFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`rootFixtureName`](../variables/rootFixtureName.md), [`GenericFixtureContext`](GenericFixtureContext.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/root.d.ts:8 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [rootFixture](../functions/rootFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/RunTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / RunTestFixture 6 | 7 | # Type Alias: RunTestFixture 8 | 9 | > **RunTestFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`runTestFixtureName`](../variables/runTestFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`RunTestFixtureOptions`](RunTestFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/run-test.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [runTestFixture](../functions/runTestFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/RunTestFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / RunTestFixtureContext 6 | 7 | # Type Alias: RunTestFixtureContext 8 | 9 | > **RunTestFixtureContext** = `Tagged`\<\{ `testResult`: `RunReturnType`\<`RunOptions`\>; \}, *typeof* [`runTestFixtureName`](../variables/runTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/run-test.d.ts:59 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [runTestFixture](../functions/runTestFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/RunTestFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / RunTestFixtureOptions 6 | 7 | # Type Alias: RunTestFixtureOptions 8 | 9 | > **RunTestFixtureOptions** = `Tagged`\<\{ `runWith`: \{ `args`: `string`[]; `binary`: `string`; `runnerOptions`: `RunOptions`; \}; \}, *typeof* [`runTestFixtureName`](../variables/runTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/run-test.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [runTestFixture](../functions/runTestFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/WebpackTestFixture.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / WebpackTestFixture 6 | 7 | # Type Alias: WebpackTestFixture 8 | 9 | > **WebpackTestFixture** = [`MockFixture`](MockFixture.md)\<*typeof* [`webpackTestFixtureName`](../variables/webpackTestFixtureName.md), [`FixtureContext`](FixtureContext.md)\<[`WebpackTestFixtureOptions`](WebpackTestFixtureOptions.md)\>\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/webpack-test.d.ts:10 12 | 13 | A [MockFixture](MockFixture.md) instantiation of this fixture. 14 | 15 | ## See 16 | 17 | [webpackTestFixture](../functions/webpackTestFixture.md) 18 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/WebpackTestFixtureContext.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / WebpackTestFixtureContext 6 | 7 | # Type Alias: WebpackTestFixtureContext 8 | 9 | > **WebpackTestFixtureContext** = `Tagged`\<\{ `testResult`: `RunReturnType`\<`RunOptions`\>; \}, *typeof* [`webpackTestFixtureName`](../variables/webpackTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/webpack-test.d.ts:45 12 | 13 | Contains any additional context properties this fixture makes available by 14 | the time its `setup` function has successfully executed. 15 | 16 | It is the sole responsibility of this fixture to ensure the context contains 17 | the mentioned properties as described. 18 | 19 | This type is Tagged so that it can be differentiated from `XContext` 20 | types provided by other fixtures, even when they contain the same properties 21 | (or no properties). 22 | 23 | ## See 24 | 25 | [webpackTestFixture](../functions/webpackTestFixture.md) 26 | -------------------------------------------------------------------------------- /docs/test/util/type-aliases/WebpackTestFixtureOptions.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / WebpackTestFixtureOptions 6 | 7 | # Type Alias: WebpackTestFixtureOptions 8 | 9 | > **WebpackTestFixtureOptions** = `Tagged`\<\{ `fileUnderTest`: `string`; `webpackVersion`: `string`; \}, *typeof* [`webpackTestFixtureName`](../variables/webpackTestFixtureName.md)\> 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/webpack-test.d.ts:20 12 | 13 | Contains any additional options properties this fixture expects or allows. 14 | 15 | This type is Tagged so that it can be differentiated from `XContext` 16 | types provided by other fixtures, even when they contain the same keys (or no 17 | keys). 18 | 19 | ## See 20 | 21 | [webpackTestFixture](../functions/webpackTestFixture.md) 22 | -------------------------------------------------------------------------------- /docs/test/util/variables/ExitErrorMessage.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / ExitErrorMessage 6 | 7 | # Variable: ExitErrorMessage 8 | 9 | > `const` **ExitErrorMessage**: `object` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-exit/dist/packages/test-mock-exit/src/error.d.ts:23 12 | 13 | A collection of possible error and warning messages. 14 | 15 | ## Type declaration 16 | 17 | ### SuppressedExitAttempt() 18 | 19 | #### Parameters 20 | 21 | ##### code 22 | 23 | `undefined` | `null` | `string` | `number` 24 | 25 | #### Returns 26 | 27 | `string` 28 | -------------------------------------------------------------------------------- /docs/test/util/variables/describeRootFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / describeRootFixtureName 6 | 7 | # Variable: describeRootFixtureName 8 | 9 | > `const` **describeRootFixtureName**: `"describe-root"` = `"describe-root"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/describe-root.d.ts:3 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/dummyDirectoriesFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyDirectoriesFixtureName 6 | 7 | # Variable: dummyDirectoriesFixtureName 8 | 9 | > `const` **dummyDirectoriesFixtureName**: `"dummy-directories"` = `"dummy-directories"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-directories.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/dummyFilesFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyFilesFixtureName 6 | 7 | # Variable: dummyFilesFixtureName 8 | 9 | > `const` **dummyFilesFixtureName**: `"dummy-files"` = `"dummy-files"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-files.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/dummyNpmPackageFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / dummyNpmPackageFixtureName 6 | 7 | # Variable: dummyNpmPackageFixtureName 8 | 9 | > `const` **dummyNpmPackageFixtureName**: `"dummy-npm-package"` = `"dummy-npm-package"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/dummy-npm-package.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/gitRepositoryFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / gitRepositoryFixtureName 6 | 7 | # Variable: gitRepositoryFixtureName 8 | 9 | > `const` **gitRepositoryFixtureName**: `"git-repository"` = `"git-repository"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/git-repository.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/globalDebugger.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / globalDebugger 6 | 7 | # Variable: globalDebugger 8 | 9 | > `const` **globalDebugger**: `ExtendedDebugger` 10 | 11 | Defined in: [test/util.ts:21](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/test/util.ts#L21) 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/globalDebuggerNamespace.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / globalDebuggerNamespace 6 | 7 | # Variable: globalDebuggerNamespace 8 | 9 | > `const` **globalDebuggerNamespace**: `"ntarh"` = `'ntarh'` 10 | 11 | Defined in: [test/util.ts:19](https://github.com/Xunnamius/next-test-api-route-handler/blob/5e0ab38964ad8658174f23f3babfa03f89d957dd/test/util.ts#L19) 12 | 13 | The project-wide namespace that appears in debugger output. Only used in 14 | tests. 15 | -------------------------------------------------------------------------------- /docs/test/util/variables/nodeImportAndRunTestFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / nodeImportAndRunTestFixtureName 6 | 7 | # Variable: nodeImportAndRunTestFixtureName 8 | 9 | > `const` **nodeImportAndRunTestFixtureName**: `"node-import-and-run-test"` = `"node-import-and-run-test"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/node-import-and-run-test.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/npmCopyPackageFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / npmCopyPackageFixtureName 6 | 7 | # Variable: npmCopyPackageFixtureName 8 | 9 | > `const` **npmCopyPackageFixtureName**: `"npm-copy-package"` = `"npm-copy-package"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-copy-package.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/npmLinkPackageFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / npmLinkPackageFixtureName 6 | 7 | # Variable: npmLinkPackageFixtureName 8 | 9 | > `const` **npmLinkPackageFixtureName**: `"npm-link-package"` = `"npm-link-package"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/npm-link-package.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/rootFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / rootFixtureName 6 | 7 | # Variable: rootFixtureName 8 | 9 | > `const` **rootFixtureName**: `"root"` = `"root"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/root.d.ts:2 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/runTestFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / runTestFixtureName 6 | 7 | # Variable: runTestFixtureName 8 | 9 | > `const` **runTestFixtureName**: `"run-test"` = `"run-test"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/run-test.d.ts:4 12 | -------------------------------------------------------------------------------- /docs/test/util/variables/webpackTestFixtureName.md: -------------------------------------------------------------------------------- 1 | [**next-test-api-route-handler**](../../../README.md) 2 | 3 | *** 4 | 5 | [next-test-api-route-handler](../../../README.md) / [test/util](../README.md) / webpackTestFixtureName 6 | 7 | # Variable: webpackTestFixtureName 8 | 9 | > `const` **webpackTestFixtureName**: `"webpack-test"` = `"webpack-test"` 10 | 11 | Defined in: node\_modules/@-xun/symbiote/node\_modules/@-xun/test-mock-fixture/dist/packages/test-mock-fixture/src/fixtures/webpack-test.d.ts:4 12 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | import { 4 | assertEnvironment, 5 | moduleExport 6 | } from '@-xun/symbiote/assets/eslint.config.mjs'; 7 | 8 | import { createDebugLogger } from 'rejoinder'; 9 | 10 | const debug = createDebugLogger({ namespace: 'symbiote:config:eslint' }); 11 | 12 | const config = await moduleExport({ 13 | derivedAliases: getEslintAliases(), 14 | ...(await assertEnvironment()) 15 | }); 16 | 17 | config.push({ 18 | /* Add custom config here, such as disabling certain rules */ 19 | }); 20 | 21 | export default config; 22 | 23 | debug('exported config: %O', config); 24 | 25 | function getEslintAliases() { 26 | // ! These aliases are auto-generated by symbiote. Instead of modifying them 27 | // ! directly, consider regenerating aliases across the entire project with: 28 | // ! `npx symbiote project renovate --regenerate-assets --assets-preset ...` 29 | return [ 30 | ['rootverse:*', './*'], 31 | ['universe:*', './src/*'], 32 | ['universe', './src/index.ts'], 33 | ['testverse:*', './test/*'], 34 | ['typeverse:*', './types/*'] 35 | ]; 36 | } 37 | -------------------------------------------------------------------------------- /external-scripts/is-next-compat.ts: -------------------------------------------------------------------------------- 1 | // ! WARNING: don't run this in the real repo dir, but in a duplicate temp dir 2 | 3 | import { getCurrentWorkingDirectory } from '@-xun/fs'; 4 | import { run, runNoRejectOnBadExit } from '@-xun/run'; 5 | import findPackageJson from 'find-package-json'; 6 | import { MongoClient } from 'mongodb'; 7 | import { createDebugLogger, createGenericLogger } from 'rejoinder'; 8 | import { satisfies as satisfiesRange, validRange } from 'semver'; 9 | 10 | import { name as packageName, version as packageVersion } from 'rootverse:package.json'; 11 | 12 | import { getNextjsReactPeerDependencies } from 'testverse:util.ts'; 13 | 14 | const log = createGenericLogger({ namespace: 'is-next-compat' }); 15 | const debug = createDebugLogger({ namespace: 'is-next-compat' }); 16 | 17 | log(`package name: "${packageName}"`); 18 | log(`package version: "${packageVersion}"`); 19 | 20 | export default main().catch((error: unknown) => { 21 | log.error(error); 22 | process.exitCode = 2; 23 | }); 24 | 25 | /** 26 | * Detect if this tool was invoked in the context of an integration test 27 | */ 28 | async function checkIfRunningInTestMode() { 29 | const isRunningInTestMode = 30 | (await runNoRejectOnBadExit('npm', ['run', '_is_next_compat_test_mode'])) 31 | .exitCode === 0; 32 | 33 | log(`test override mode: ${isRunningInTestMode ? 'ACTIVE' : 'inactive'}`); 34 | return isRunningInTestMode; 35 | } 36 | 37 | /** 38 | * Update remote DB with the new information so that the badge stays current. 39 | */ 40 | async function setCompatFlagTo(version: string) { 41 | try { 42 | if (await checkIfRunningInTestMode()) { 43 | log('skipped updating database (test override mode)'); 44 | } else { 45 | const semverRange = process.env.NODE_TARGET_VERSION; 46 | log(`saw potential semver range: ${semverRange ?? '(undefined)'}`); 47 | 48 | if ( 49 | validRange(semverRange) && 50 | !satisfiesRange(process.versions.node, semverRange!) 51 | ) { 52 | log( 53 | `skipped updating database (node version ${process.versions.node} not in range)` 54 | ); 55 | } else { 56 | /* istanbul ignore next */ 57 | if (process.env.MONGODB_URI) { 58 | const client = await MongoClient.connect(process.env.MONGODB_URI); 59 | 60 | // ? Update database 61 | await client 62 | .db('pkg-compat') 63 | .collection('flags') 64 | .updateOne( 65 | { name: 'ntarh-next' }, 66 | { $set: { value: version } }, 67 | { upsert: true } 68 | ); 69 | 70 | await client.close(); 71 | 72 | log(`updated database compat: "${version}"`); 73 | } else log('skipped updating database (no MONGODB_URI)'); 74 | } 75 | } 76 | } catch (error) { 77 | log.warn('an attempt to update the database failed'); 78 | throw error; 79 | } 80 | } 81 | 82 | /** 83 | * The is-next-compat runtime. 84 | * 85 | * This tool looks for a `_is_next_compat_test_mode` npm script with a zero exit 86 | * code. If found, no DB connections will be made. Should appear in integration 87 | * tests' package files to prevent those tests from making DB connections using 88 | * a project's (potentially production) .env values. 89 | * 90 | * ``` 91 | * "scripts": { 92 | * "_is_next_compat_test_mode": "true" 93 | * } 94 | * ``` 95 | */ 96 | async function main() { 97 | log('connecting to GitHub'); 98 | 99 | if (!process.env.GH_TOKEN) log('warning: not using a personal access token!'); 100 | 101 | const { Octokit } = await import('@octokit/rest'); 102 | 103 | const { repos } = new Octokit({ 104 | auth: process.env.GH_TOKEN, 105 | userAgent: `${packageName}@${packageVersion}` 106 | }); 107 | 108 | const { 109 | data: { tag_name: latestVersion } 110 | } = await repos.getLatestRelease({ 111 | owner: 'vercel', 112 | repo: 'next.js' 113 | }); 114 | 115 | const latestReleaseVersion = latestVersion.replace(/^v/, ''); 116 | log(`saw latest release version "${latestReleaseVersion}"`); 117 | 118 | if (!latestReleaseVersion) throw new Error('could not find latest Next.js version'); 119 | 120 | const { filename: path } = findPackageJson(getCurrentWorkingDirectory()).next(); 121 | log(`using path: %O`, path); 122 | 123 | if (!path) { 124 | throw new Error('could not find package.json'); 125 | } 126 | 127 | const nextVersionUnderTestFullNameAndVersion = `next@${latestReleaseVersion}`; 128 | 129 | log('installing %O for unit tests', nextVersionUnderTestFullNameAndVersion); 130 | log('(integration tests use their own Next.js versions)'); 131 | 132 | // ? Install peer deps manually for Next.js 133 | const nextLatestReleaseVersionPeerDependencies = await getNextjsReactPeerDependencies( 134 | nextVersionUnderTestFullNameAndVersion 135 | ); 136 | 137 | await run('npm', [ 138 | 'install', 139 | '--no-save', 140 | '--force', 141 | nextVersionUnderTestFullNameAndVersion, 142 | ...nextLatestReleaseVersionPeerDependencies 143 | ]); 144 | 145 | log('attempting to repair node_modules after install using %O', 'npm run prepare'); 146 | 147 | const { exitCode, all } = await runNoRejectOnBadExit('npm', ['run', 'prepare'], { 148 | all: true 149 | }); 150 | 151 | if (exitCode !== 0) { 152 | debug.warn('%O command did not complete successfully: %O', 'npm run prepare', all); 153 | } 154 | 155 | log('running compatibility tests'); 156 | 157 | await run('npm', ['run', 'test:packages:all']); 158 | 159 | log('test succeeded'); 160 | 161 | await setCompatFlagTo(latestReleaseVersion); 162 | 163 | log('execution complete'); 164 | 165 | process.exitCode = 0; 166 | } 167 | -------------------------------------------------------------------------------- /gac.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 5 | import { moduleExport } from '@-xun/symbiote/assets/gac.config.mjs'; 6 | import { createDebugLogger } from 'rejoinder'; 7 | 8 | const debug = createDebugLogger({ namespace: 'symbiote:config:gac' }); 9 | 10 | const config = deepMergeConfig(moduleExport(), { 11 | // Any custom configs here will be deep merged with moduleExport's result 12 | }); 13 | 14 | export default config; 15 | 16 | debug('exported config: %O', config); 17 | -------------------------------------------------------------------------------- /jest.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 5 | 6 | import { 7 | assertEnvironment, 8 | moduleExport, 9 | transformSelectEsmPackagesToCjs 10 | } from '@-xun/symbiote/assets/jest.config.mjs'; 11 | 12 | import { createDebugLogger } from 'rejoinder'; 13 | 14 | const debug = createDebugLogger({ namespace: 'symbiote:config:jest' }); 15 | 16 | const config = deepMergeConfig( 17 | moduleExport({ derivedAliases: getJestAliases(), ...assertEnvironment() }), 18 | { 19 | // Any custom configs here will be deep merged with moduleExport's result 20 | } 21 | ); 22 | 23 | transformSelectEsmPackagesToCjs(config, [ 24 | '@octokit', 25 | 'universal-user-agent', 26 | 'before-after-hook' 27 | ]); 28 | 29 | export default config; 30 | 31 | debug('exported config: %O', config); 32 | 33 | function getJestAliases() { 34 | const extension = process.env.SYMBIOTE_TEST_JEST_TRANSPILED ? 'js' : 'ts'; 35 | 36 | // ! These aliases are auto-generated by symbiote. Instead of modifying them 37 | // ! directly, consider regenerating aliases across the entire project with: 38 | // ! `npx symbiote project renovate --regenerate-assets --assets-preset ...` 39 | return { 40 | '^universe:(.+)$': '/src/$1', 41 | '^universe$': `/src/index.${extension}`, 42 | '^testverse:(.+)$': '/test/$1', 43 | '^typeverse:(.+)$': '/types/$1', 44 | '^rootverse:(.+)$': '/$1' 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /lint-staged.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 5 | import { moduleExport } from '@-xun/symbiote/assets/lint-staged.config.mjs'; 6 | import { createDebugLogger } from 'rejoinder'; 7 | 8 | const debug = createDebugLogger({ namespace: 'symbiote:config:lint-staged' }); 9 | 10 | const config = deepMergeConfig(moduleExport(), { 11 | // Any custom configs here will be deep merged with moduleExport's result 12 | }); 13 | 14 | export default config; 15 | 16 | debug('exported config: %O', config); 17 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xunnamius/next-test-api-route-handler/d97e8ba446584652b13490265b04b6f71975e705/logo.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-test-api-route-handler", 3 | "version": "4.0.16", 4 | "description": "Confidently unit and integration test your Next.js API routes/handlers in an isolated Next.js-like environment", 5 | "keywords": [ 6 | "api", 7 | "route", 8 | "next", 9 | "unit", 10 | "test", 11 | "endpoint", 12 | "testing", 13 | "nextjs", 14 | "next.js", 15 | "handler", 16 | "request", 17 | "response", 18 | "jest" 19 | ], 20 | "homepage": "https://github.com/Xunnamius/next-test-api-route-handler#readme", 21 | "bugs": { 22 | "url": "https://github.com/Xunnamius/next-test-api-route-handler/issues" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "git+https://github.com/Xunnamius/next-test-api-route-handler.git" 27 | }, 28 | "license": "MIT", 29 | "author": "Xunnamius", 30 | "sideEffects": false, 31 | "type": "commonjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/src/index.d.ts", 35 | "default": "./dist/src/index.js" 36 | }, 37 | "./package": "./package.json", 38 | "./package.json": "./package.json" 39 | }, 40 | "typesVersions": { 41 | "*": { 42 | "index": [ 43 | "dist/src/index.d.ts" 44 | ], 45 | "package": [ 46 | "package.json" 47 | ] 48 | } 49 | }, 50 | "files": [ 51 | "/dist", 52 | "/LICENSE", 53 | "/package.json", 54 | "/README.md" 55 | ], 56 | "scripts": { 57 | "build": "npm run build:dist --", 58 | "build:changelog": "symbiote build changelog --env NODE_NO_WARNINGS=1", 59 | "build:dist": "symbiote build distributables --env NODE_NO_WARNINGS=1 --not-multiversal", 60 | "build:docs": "symbiote build docs --env NODE_NO_WARNINGS=1", 61 | "build:externals": "echo '\nWARNING: this script and the whole concept of so-called \"externals\" is going away soon (to be replaced by a hybridrepo)!\n\n'; EXTERNAL_DELETE_THIS=true NODE_ENV=production-cjs babel external-scripts --extensions .ts --out-dir external-scripts/bin && NODE_ENV=production-cjs babel test/util.ts --extensions .ts --out-dir external-scripts/bin", 62 | "clean": "symbiote clean --env NODE_NO_WARNINGS=1", 63 | "format": "symbiote format --env NODE_NO_WARNINGS=1 --hush", 64 | "info": "symbiote project info --env NODE_NO_WARNINGS=1", 65 | "lint": "npm run lint:package --", 66 | "lint:package": "symbiote lint --env NODE_NO_WARNINGS=1 --hush", 67 | "lint:packages": "symbiote lint --env NODE_NO_WARNINGS=1 --hush --scope unlimited", 68 | "lint:project": "symbiote project lint --env NODE_NO_WARNINGS=1", 69 | "list-tasks": "symbiote list-tasks --env NODE_NO_WARNINGS=1 --scope this-package", 70 | "prepare": "symbiote project prepare --env NODE_NO_WARNINGS=1", 71 | "release": "npm run build:externals && symbiote release --env NODE_NO_WARNINGS=1", 72 | "renovate": "symbiote project renovate --env NODE_NO_WARNINGS=1 --github-reconfigure-repo --regenerate-assets --assets-preset lib", 73 | "renovate:aliases": "symbiote project renovate --env NODE_NO_WARNINGS=1 --regenerate-assets --assets-preset lib --only-aliases", 74 | "start": "symbiote start --env NODE_NO_WARNINGS=1 --", 75 | "test": "npm run test:package:unit --", 76 | "test:package:all": "symbiote test --env NODE_NO_WARNINGS=1 --tests all-local --coverage", 77 | "test:package:e2e": "symbiote test --env NODE_NO_WARNINGS=1 --tests e2e-local", 78 | "test:package:integration": "symbiote test --env NODE_NO_WARNINGS=1 --tests integration", 79 | "test:package:unit": "symbiote test --env NODE_NO_WARNINGS=1 --tests unit type", 80 | "test:packages:all": "symbiote test --env NODE_NO_WARNINGS=1 --tests all-local --scope unlimited --coverage", 81 | "test:packages:all:unit": "symbiote test --env NODE_NO_WARNINGS=1 --tests unit type --scope unlimited --coverage" 82 | }, 83 | "dependencies": { 84 | "@whatwg-node/server": "^0.10.10", 85 | "cookie": "^1.0.2", 86 | "core-js": "^3.42.0" 87 | }, 88 | "devDependencies": { 89 | "@-xun/fs": "^2.0.0", 90 | "@-xun/project-fs": "^2.0.1", 91 | "@-xun/run": "^1.1.0", 92 | "@-xun/symbiote": "^4.2.7", 93 | "@octokit/rest": "^22.0.0", 94 | "@types/find-package-json": "^1.2.6", 95 | "@types/semver": "^7.7.0", 96 | "find-package-json": "^1.2.0", 97 | "mongodb": "^6.17.0", 98 | "msw": "^2.9.0", 99 | "rejoinder": "^1.2.5", 100 | "semver": "^7.7.2" 101 | }, 102 | "peerDependencies": { 103 | "next": ">=9" 104 | }, 105 | "engines": { 106 | "node": "^20.18.0 || >=22.12.0" 107 | }, 108 | "publishConfig": { 109 | "access": "public", 110 | "registry": "https://registry.npmjs.org" 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /prettier.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | import { deepMergeConfig } from '@-xun/symbiote/assets'; 5 | import { moduleExport } from '@-xun/symbiote/assets/prettier.config.mjs'; 6 | import { createDebugLogger } from 'rejoinder'; 7 | 8 | const debug = createDebugLogger({ namespace: 'symbiote:config:prettier' }); 9 | 10 | const config = deepMergeConfig(moduleExport(), { 11 | // Any custom configs here will be deep merged with moduleExport's result 12 | }); 13 | 14 | export default config; 15 | 16 | debug('exported config: %O', config); 17 | -------------------------------------------------------------------------------- /release.config.cjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 'use strict'; 3 | 4 | const { deepMergeConfig } = require('@-xun/symbiote/assets'); 5 | 6 | const { 7 | assertEnvironment, 8 | moduleExport 9 | } = require('@-xun/symbiote/assets/release.config.cjs'); 10 | 11 | const { createDebugLogger } = require('rejoinder'); 12 | 13 | const debug = createDebugLogger({ namespace: 'symbiote:config:release' }); 14 | 15 | module.exports = deepMergeConfig( 16 | moduleExport(assertEnvironment({ projectRoot: __dirname })), 17 | { 18 | // Any custom configs here will be deep merged with moduleExport's result 19 | } 20 | ); 21 | 22 | debug('exported config: %O', module.exports); 23 | -------------------------------------------------------------------------------- /test/integration/integration-smoke-external.test.ts: -------------------------------------------------------------------------------- 1 | // * These brutally minimal "smoke" tests ensure the externals can be invoked 2 | // * and, when it is, exits cleanly. Functionality testing is not the goal here. 3 | 4 | import { toAbsolutePath } from '@-xun/fs'; 5 | import { isAccessible } from '@-xun/project-fs'; 6 | import { runnerFactory } from '@-xun/run'; 7 | 8 | import { peerDependencies } from 'rootverse:package.json'; 9 | 10 | import { 11 | dummyNpmPackageFixture, 12 | globalDebugger, 13 | mockFixturesFactory, 14 | reconfigureJestGlobalsToSkipTestsInThisFileIfRequested 15 | } from 'testverse:util.ts'; 16 | 17 | reconfigureJestGlobalsToSkipTestsInThisFileIfRequested({ it: true }); 18 | 19 | const TEST_IDENTIFIER = 'ntarh-client-changelog'; 20 | const EXTERNAL_BIN_PATH = toAbsolutePath( 21 | __dirname, 22 | '..', 23 | '..', 24 | 'external-scripts', 25 | 'bin', 26 | 'is-next-compat.js' 27 | ); 28 | 29 | const debug = globalDebugger.extend(TEST_IDENTIFIER); 30 | const runExternal = runnerFactory('node', ['--no-warnings', EXTERNAL_BIN_PATH]); 31 | const nodeVersion = process.env.MATRIX_NODE_VERSION || process.version; 32 | 33 | debug(`nodeVersion: "${nodeVersion}"`); 34 | 35 | beforeAll(async () => { 36 | // TODO: remove this customization once externals retired 37 | if (!(await isAccessible(EXTERNAL_BIN_PATH, { useCached: false }))) { 38 | throw new Error('must build externals first (try `npm run build:externals`)'); 39 | } 40 | }); 41 | 42 | const withMockedFixture = mockFixturesFactory([dummyNpmPackageFixture], { 43 | performCleanup: true, 44 | identifier: TEST_IDENTIFIER, 45 | // ? We use _is_next_compat_test_mode to prevent the external script (compiled 46 | // ? using a .env file potentially with production keys) from attempting 47 | // ? external connections 48 | initialVirtualFiles: { 49 | 'package.json': `{ 50 | "name": "dummy-pkg", 51 | "scripts": { 52 | "test:packages:all": "true", 53 | "_is_next_compat_test_mode": "true" 54 | }, 55 | "peerDependencies": { 56 | "next": "${peerDependencies.next}" 57 | } 58 | }` 59 | } 60 | }); 61 | 62 | it('runs to completion', async () => { 63 | expect.hasAssertions(); 64 | 65 | await withMockedFixture(async ({ root }) => { 66 | const { exitCode, stdout, stderr } = await runExternal(undefined, { cwd: root }); 67 | 68 | expect(stdout).toStrictEqual(expect.stringContaining('execution complete')); 69 | expect(stderr).toBeEmpty(); 70 | 71 | expect(exitCode).toBe(0); 72 | }); 73 | }); 74 | -------------------------------------------------------------------------------- /test/setup.ts: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file is automatically imported by Jest, and is responsible for 3 | ** bootstrapping the runtime for every test file. 4 | */ 5 | 6 | // ? jest-extended will always come from @-xun/symbiote (i.e. transitively) 7 | // {@symbiote/notInvalid jest-extended} 8 | 9 | // ? https://github.com/jest-community/jest-extended#typescript 10 | import 'jest-extended'; 11 | import 'jest-extended/all'; 12 | -------------------------------------------------------------------------------- /test/type.test.ts: -------------------------------------------------------------------------------- 1 | import { NextResponse } from 'next/server'; 2 | import { describe, expect, it } from 'tstyche'; 3 | 4 | import { testApiHandler } from 'universe'; 5 | 6 | import type { NextRequest } from 'next/server'; 7 | import type { NtarhInitAppRouter } from 'universe'; 8 | 9 | describe('::testApiHandler', () => { 10 | describe('', () => { 11 | it('supports type generics', async () => { 12 | await testApiHandler<{ a: number }>({ 13 | appHandler: { 14 | async GET() { 15 | // ? We shouldn't be type checking this deep 16 | return Response.json({ b: 1 }); 17 | } 18 | }, 19 | test: async ({ fetch }) => { 20 | expect(await (await fetch()).json()).type.toHaveProperty('a'); 21 | expect(await (await fetch()).json()).type.not.toHaveProperty('b'); 22 | } 23 | }); 24 | }); 25 | 26 | it('does not throw any AppRouteUserlandModule-related type errors', async () => { 27 | expect({ 28 | async GET(_req: NextRequest, _params: { params: { recipeId: string } }) { 29 | return NextResponse.json({}); 30 | } 31 | }).type.toBeAssignableTo(); 32 | 33 | expect({ 34 | async LOL() { 35 | return NextResponse.json({}); 36 | }, 37 | async GET(_req: NextRequest, _params: { params: { recipeId: string } }) { 38 | return NextResponse.json({}); 39 | } 40 | }).type.not.toBeAssignableTo(); 41 | }); 42 | }); 43 | 44 | describe('', () => { 45 | it('supports type generics', async () => { 46 | await testApiHandler<{ a: number }>({ 47 | pagesHandler: async (_, res) => { 48 | // ? Formerly we would expect an error to be thrown here, but in 49 | // ? NTARH@4 we've relaxed the type checking so that only fetch::json 50 | // ? is affected. I believe this leads to more accurate and more 51 | // ? useful type checking for NTARH users. 52 | res.send({ b: 1 }); 53 | }, 54 | test: async ({ fetch }) => { 55 | expect(await (await fetch()).json()).type.toHaveProperty('a'); 56 | expect(await (await fetch()).json()).type.not.toHaveProperty('b'); 57 | } 58 | }); 59 | }); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /test/unit-msw.test.ts: -------------------------------------------------------------------------------- 1 | // * These tests ensure NTARH and MSW integrate as expected 2 | 3 | import { http, HttpResponse, passthrough } from 'msw'; 4 | import { setupServer } from 'msw/node'; 5 | 6 | import { testApiHandler } from 'universe'; 7 | 8 | const server = setupServer( 9 | http.all('*', async ({ request, params }) => { 10 | const { method, headers } = request; 11 | const body = await request.text(); 12 | 13 | return HttpResponse.json( 14 | { method, headers: Array.from(headers), params, body }, 15 | { 16 | status: body.startsWith('status=') 17 | ? Number.parseInt(body.split('status=').at(-1) || '200') 18 | : 200 19 | } 20 | ); 21 | }) 22 | ); 23 | 24 | beforeAll(() => server.listen({ onUnhandledRequest: 'error' })); 25 | 26 | afterEach(() => { 27 | server.resetHandlers(); 28 | }); 29 | 30 | afterAll(() => server.close()); 31 | 32 | describe('', () => { 33 | it('bypasses msw by default', async () => { 34 | expect.hasAssertions(); 35 | 36 | await testApiHandler({ 37 | rejectOnHandlerError: true, 38 | appHandler: { 39 | GET() { 40 | return Response.json({ from: 'ntarh' }, { status: 200 }); 41 | } 42 | }, 43 | async test({ fetch }) { 44 | const res = await fetch({ method: 'GET' }); 45 | const json = await res.json(); 46 | 47 | expect(json).toStrictEqual({ from: 'ntarh' }); 48 | } 49 | }); 50 | }); 51 | 52 | it('does not bypass msw if header is explicitly disabled (README example)', async () => { 53 | expect.hasAssertions(); 54 | 55 | // e.g. https://xunn.at/gg => https://www.google.com/search?q=next-test-api-route-handler 56 | // shortId would be "gg" 57 | // realLink would be https://www.google.com/search?q=next-test-api-route-handler 58 | 59 | const { shortId, realLink } = getUriEntry(); 60 | const realUrl = new URL(realLink); 61 | 62 | await testApiHandler({ 63 | appHandler, 64 | params: { shortId }, 65 | test: async ({ fetch }) => { 66 | server.use( 67 | http.get('*', async ({ request }) => { 68 | return request.url === realUrl.href 69 | ? HttpResponse.json({ it: 'worked' }, { status: 200 }) 70 | : passthrough(); 71 | }) 72 | ); 73 | 74 | const res = await fetch({ 75 | headers: { 'x-msw-intention': 'none' } // <== 76 | }); 77 | 78 | await expect(res.json()).resolves.toMatchObject({ it: 'worked' }); 79 | expect(res.status).toBe(200); 80 | } 81 | }); 82 | }); 83 | }); 84 | 85 | describe('', () => { 86 | it('bypasses msw by default', async () => { 87 | expect.hasAssertions(); 88 | 89 | await testApiHandler({ 90 | rejectOnHandlerError: true, 91 | pagesHandler(_, res) { 92 | res.status(200).send({ from: 'ntarh' }); 93 | }, 94 | async test({ fetch }) { 95 | const res = await fetch({ method: 'POST' }); 96 | const json = await res.json(); 97 | 98 | expect(json).toStrictEqual({ from: 'ntarh' }); 99 | } 100 | }); 101 | }); 102 | 103 | it('does not bypass msw if header is explicitly disabled (README example)', async () => { 104 | expect.hasAssertions(); 105 | 106 | // e.g. https://xunn.at/gg => https://www.google.com/search?q=next-test-api-route-handler 107 | // shortId would be "gg" 108 | // realLink would be https://www.google.com/search?q=next-test-api-route-handler 109 | 110 | const { shortId, realLink } = getUriEntry(); 111 | const realUrl = new URL(realLink); 112 | 113 | await testApiHandler({ 114 | pagesHandler, 115 | params: { shortId }, 116 | test: async ({ fetch }) => { 117 | server.use( 118 | http.get('*', async ({ request }) => { 119 | return request.url === realUrl.href 120 | ? HttpResponse.json({ it: 'worked' }, { status: 200 }) 121 | : passthrough(); 122 | }) 123 | ); 124 | 125 | const res = await fetch({ 126 | headers: { 'x-msw-intention': 'none' } // <== 127 | }); 128 | 129 | await expect(res.json()).resolves.toMatchObject({ it: 'worked' }); 130 | expect(res.status).toBe(200); 131 | } 132 | }); 133 | }); 134 | }); 135 | 136 | const appHandler = { 137 | async GET() { 138 | return Response.json(await (await fetch(getUriEntry().realLink)).json()); 139 | } 140 | }; 141 | 142 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 143 | async function pagesHandler(_: any, res: any) { 144 | return res.status(200).send(await (await fetch(getUriEntry().realLink)).json()); 145 | } 146 | 147 | function getUriEntry() { 148 | return { 149 | shortId: 'gg', 150 | realLink: 'https://www.google.com/search?q=next-test-api-route-handler' 151 | }; 152 | } 153 | -------------------------------------------------------------------------------- /test/util.ts: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file exports test utilities specific to this project and beyond what is 3 | ** exported by @-xun/jest; these can be imported using the testversal aliases. 4 | */ 5 | 6 | // ? @-xun/jest will always come from @-xun/symbiote (i.e. transitively) 7 | // {@symbiote/notInvalid @-xun/jest} 8 | 9 | import { run } from '@-xun/run'; 10 | import { createDebugLogger } from 'rejoinder'; 11 | import { maxSatisfying } from 'semver'; 12 | 13 | export * from '@-xun/jest'; 14 | 15 | /** 16 | * The project-wide namespace that appears in debugger output. Only used in 17 | * tests. 18 | */ 19 | export const globalDebuggerNamespace = 'ntarh'; 20 | 21 | export const globalDebugger = createDebugLogger({ namespace: globalDebuggerNamespace }); 22 | 23 | /** 24 | * Since some versions of Next.js are released with flawed 25 | * `package.json::peerDependencies`, sometimes we need to ensure the correct 26 | * versions of Next.js's peer dependencies are actually installed. 27 | */ 28 | export async function getNextjsReactPeerDependencies( 29 | /** 30 | * For example: `next`, `next@latest`, or `next@15.0.0-rc.1` 31 | */ 32 | npmInstallNextJsString: string 33 | ): Promise { 34 | const debug = globalDebugger.extend('getNextPeerDependencies'); 35 | 36 | return Promise.all([ 37 | run('npm', ['show', 'react', 'versions', '--json']), 38 | run('npm', ['show', 'react-dom', 'versions', '--json']), 39 | run('npm', ['show', npmInstallNextJsString, 'peerDependencies', '--json']) 40 | ]).then(function ([ 41 | { stdout: reactVersions_ }, 42 | { stdout: reactDomVersions_ }, 43 | { stdout: nextPeerDependencies_ } 44 | ]) { 45 | debug('reactVersions: %O bytes', reactVersions_.length); 46 | debug('reactDomVersions: %O bytes', reactDomVersions_.length); 47 | debug('nextPeerDependencies: %O bytes', nextPeerDependencies_.length); 48 | 49 | const reactVersions: string[] = JSON.parse(reactVersions_); 50 | const reactDomVersions: string[] = JSON.parse(reactDomVersions_); 51 | const nextPeerDependencies: Record<'react' | 'react-dom', string> = 52 | JSON.parse(nextPeerDependencies_); 53 | 54 | const reactVersion = 55 | typeof nextPeerDependencies.react === 'string' 56 | ? maxSatisfying(reactVersions, nextPeerDependencies.react) 57 | : undefined; 58 | 59 | const reactDomVersion = 60 | typeof nextPeerDependencies['react-dom'] === 'string' 61 | ? maxSatisfying(reactDomVersions, nextPeerDependencies['react-dom']) 62 | : undefined; 63 | 64 | const finalPeerDeps = [ 65 | reactVersion ? `react@${reactVersion}` : '', 66 | reactDomVersion ? `react-dom@${reactDomVersion}` : '' 67 | ].filter(Boolean); 68 | 69 | debug('finalPeerDeps: %O', finalPeerDeps); 70 | return finalPeerDeps; 71 | }); 72 | } 73 | -------------------------------------------------------------------------------- /tsc.package.docs.json: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file extends the project root tsconfig.json file for use with 3 | ** typedoc at the package level. 4 | ** 5 | ** Use this file to exert some control over how typedoc generates 6 | ** package-specific documentation. 7 | */ 8 | 9 | { 10 | "$schema": "https://json.schemastore.org/tsconfig.json", 11 | "extends": "./tsconfig.json", 12 | "include": ["types/**/*", "src/**/*", "test/**/*"], 13 | "exclude": [ 14 | "**/dist/**/*", 15 | "**/test/fixtures/**/*", 16 | "**/node_modules/**/*", 17 | "packages/**/*", 18 | "packages/**/.*", 19 | "**/*.ignore", 20 | "**/*.ignore.*/**/*", 21 | "**/ignore.*" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tsc.package.lint.json: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file extends the project root tsconfig.json file for use with linting 3 | ** all files at the package level. Only tsc gets its paths from this file. 4 | ** 5 | ** Use this file to exert some control over which files are considered 6 | ** part of the current package and which will be ignored. 7 | */ 8 | 9 | { 10 | "$schema": "https://json.schemastore.org/tsconfig.json", 11 | "extends": "./tsconfig.json", 12 | "include": ["**/*", "**/.*/**/*", "**/.*"], 13 | "exclude": [ 14 | "**/dist/**/*", 15 | "**/test/fixtures/**/*", 16 | "**/node_modules/**/*", 17 | "packages/**/*", 18 | "packages/**/.*", 19 | "**/*.ignore", 20 | "**/*.ignore.*/**/*", 21 | "**/ignore.*" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tsc.package.types.json: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file extends the project root tsconfig.json file for use with tsc at 3 | ** the package level. 4 | ** 5 | ** Use this file to exert some control over how tsc generates package-specific 6 | ** definition files. 7 | */ 8 | 9 | { 10 | "$schema": "https://json.schemastore.org/tsconfig.json", 11 | "extends": "./tsconfig.json", 12 | "compilerOptions": { 13 | "allowJs": false, 14 | "checkJs": false, 15 | "declaration": true, 16 | "emitDeclarationOnly": true, 17 | "isolatedModules": false, 18 | "noEmit": false, 19 | "outDir": "dist", 20 | "rootDir": "./" 21 | }, 22 | "include": ["types/**/*", "src/**/*"], 23 | "exclude": [ 24 | "**/dist/**/*", 25 | "**/test/fixtures/**/*", 26 | "**/node_modules/**/*", 27 | "packages/**/*", 28 | "packages/**/.*", 29 | "**/*.ignore", 30 | "**/*.ignore.*/**/*", 31 | "**/ignore.*" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /tsc.project.lint.json: -------------------------------------------------------------------------------- 1 | /** 2 | ** This file extends the project root tsconfig.json file for use with linting 3 | ** all files at the project level. 4 | ** 5 | ** Use this file to exert some control over which files will have their errors 6 | ** reported and which files will be ignored when linting an entire project 7 | ** repository at once. 8 | */ 9 | 10 | { 11 | "$schema": "https://json.schemastore.org/tsconfig.json", 12 | "extends": "./tsconfig.json", 13 | "include": ["**/*", "**/.*/**/*", "**/.*"], 14 | "exclude": [ 15 | "**/dist/**/*", 16 | "**/test/fixtures/**/*", 17 | "**/node_modules/**/*", 18 | "**/*.ignore", 19 | "**/*.ignore.*/**/*", 20 | "**/ignore.*" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // ? Needed to type check our various .js files 4 | "allowJs": true, 5 | "allowSyntheticDefaultImports": true, 6 | // ? Due to paths, the effect of this prop is limited (already covered) 7 | "allowImportingTsExtensions": true, 8 | // ? Due to paths, the effect of this prop is limited (often ignored) 9 | "allowArbitraryExtensions": true, 10 | "alwaysStrict": true, 11 | "baseUrl": ".", 12 | // ? Does too much; opt-in (provided by allowJs) is better 13 | "checkJs": false, 14 | "jsx": "preserve", 15 | "declaration": false, 16 | "esModuleInterop": true, 17 | "forceConsistentCasingInFileNames": true, 18 | "incremental": true, 19 | "inlineSourceMap": true, 20 | "isolatedModules": true, 21 | // ? Tried it. Not a fan. Also conflicts with allowJs 22 | "isolatedDeclarations": false, 23 | "lib": [ 24 | "ESNext", 25 | "DOM", 26 | "WebWorker.ImportScripts", 27 | "ScriptHost", 28 | "DOM.Iterable" 29 | ], 30 | "module": "NodeNext", 31 | "moduleResolution": "NodeNext", 32 | "noEmit": true, 33 | "noErrorTruncation": true, 34 | "noImplicitAny": true, 35 | "noImplicitOverride": true, 36 | "noUncheckedIndexedAccess": true, 37 | // ? Disabled in favor of @typescript-eslint/no-unused-vars 38 | "noUnusedLocals": false, 39 | // ? Disabled in favor of @typescript-eslint/no-unused-vars 40 | "noUnusedParameters": false, 41 | // ! These aliases are auto-generated by symbiote. Instead of modifying them 42 | // ! directly, consider regenerating aliases across the entire project with: 43 | // ! `npx symbiote project renovate --regenerate-assets --assets-preset ...` 44 | "paths": { 45 | "universe": ["src/index.ts"], 46 | "universe:*": ["src/*"], 47 | "testverse:*": ["test/*"], 48 | "typeverse:*": ["types/*"], 49 | "rootverse:*": ["*"] 50 | }, 51 | "resolveJsonModule": true, 52 | "skipLibCheck": true, 53 | "strict": true, 54 | "target": "ESNext" 55 | }, 56 | "include": [ 57 | "types/**/*", 58 | "src/**/*", 59 | "test/**/*", 60 | "packages/*/src/**/*", 61 | "packages/*/test/**/*", 62 | "external-scripts/**/*" 63 | ], 64 | "exclude": [ 65 | "**/dist/**/*", 66 | "**/node_modules/**/*", 67 | "**/*.ignore", 68 | "**/*.ignore.*/**/*", 69 | "**/ignore.*" 70 | ] 71 | } 72 | -------------------------------------------------------------------------------- /tstyche.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://tstyche.org/schemas/config.json#{@symbiote/notInvalid tstyche}", 3 | "testFileMatch": [ 4 | "**/type.test.ts", 5 | "**/type.test.tsx", 6 | "**/type-*.test.ts", 7 | "**/type-*.test.tsx" 8 | ], 9 | "rejectAnyType": true, 10 | "rejectNeverType": true 11 | } 12 | -------------------------------------------------------------------------------- /very-first-version-of-ntarh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xunnamius/next-test-api-route-handler/d97e8ba446584652b13490265b04b6f71975e705/very-first-version-of-ntarh.png --------------------------------------------------------------------------------