mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5745] feat(common): add collection-level pre-request and test scripts #5334
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5334
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5745
Author: @johnan319
Created: 1/5/2026
Status: 🔄 Open
Base:
main← Head:feat/collection-level-scripts📝 Commits (10+)
217584efeat(common): add collection-level pre-request and test scripts943912efix: address review feedback7cf2698fix: update test mocks to use v12 collection schema3ceae08fix: wrap inherited scripts in IIFE to prevent variable clashes6c22e6dMerge branch 'main' into feat/collection-level-scriptsa3a6cebfix: prevent array mutation and enable async/await in script IIFEs4be8fa2fix(cli): strip module prefix and support async/await in script IIFEs04c9401Merge branch 'main' into feat/collection-level-scripts205038cfeat: add collection-level pre-request and test script inheritancea3ca2eechore: remove unnecessary comments📊 Changes
55 files changed (+1708 additions, -188 deletions)
View changed files
📝
packages/hoppscotch-backend/src/team-collection/team-collection.service.ts(+35 -20)📝
packages/hoppscotch-backend/src/team-request/team-request.service.ts(+15 -13)📝
packages/hoppscotch-backend/src/user-collection/user-collection.service.ts(+34 -18)📝
packages/hoppscotch-cli/src/__tests__/unit/fixtures/workspace-access.mock.ts(+56 -12)➕
packages/hoppscotch-cli/src/__tests__/unit/pre-request-inheritance.spec.ts(+172 -0)➕
packages/hoppscotch-cli/src/__tests__/unit/scripting.spec.ts(+138 -0)➕
packages/hoppscotch-cli/src/__tests__/unit/test-runner-inheritance.spec.ts(+194 -0)📝
packages/hoppscotch-cli/src/interfaces/response.ts(+2 -0)📝
packages/hoppscotch-cli/src/types/request.ts(+2 -0)📝
packages/hoppscotch-cli/src/utils/collections.ts(+17 -2)📝
packages/hoppscotch-cli/src/utils/pre-request.ts(+18 -3)📝
packages/hoppscotch-cli/src/utils/request.ts(+14 -6)➕
packages/hoppscotch-cli/src/utils/scripting.ts(+54 -0)📝
packages/hoppscotch-cli/src/utils/test.ts(+16 -3)📝
packages/hoppscotch-cli/src/utils/workspace-access.ts(+6 -0)📝
packages/hoppscotch-common/locales/en.json(+5 -0)📝
packages/hoppscotch-common/src/components.d.ts(+1 -0)📝
packages/hoppscotch-common/src/components/collections/Properties.vue(+150 -1)📝
packages/hoppscotch-common/src/components/collections/documentation/index.vue(+4 -0)📝
packages/hoppscotch-common/src/components/collections/graphql/Add.vue(+3 -0)...and 35 more files
📄 Description
Summary
Adds support for defining pre-request and test scripts at the collection level, which are inherited by all requests within that collection. This reduces code duplication when multiple requests need the same script logic (e.g., authentication token refresh).
Changes
preRequestScriptandtestScriptfieldsscriptsproperty toHoppInheritedPropertytypeCloses #3728
Summary by cubic
Adds collection-level pre-request and test scripts that inherit through the collection tree. Scripts run in order with isolated scope across app, CLI, and test runner; Postman collection/folder scripts are imported. Closes #3728.
New Features
Bug Fixes
Written for commit
8e5fa6f7f5. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.