All types of functions include appropriate context bound to this
:
Provides the full context of the suite.
💡 Chain requests by assigning data to
this.suite
to utilize in subsequent specs
Available in:
before_all
after_all
before_each
after_each
before_test
after_test
1link - name: get user
2link request:
3link path: /user
4link method: get
5link before_test:
6link run_type: module
7link module:
8link function: !!js/function >
9link function () {
10link this.suite.user = JSON.parse(this.response.body);
11link }
12link - name: get addresses
13link request:
14link path: /users/{userId}/addresses
15link method: get
16link after_test:
17link run_type: module
18link module:
19link function: !!js/function >
20link function () {
21link const { id } = this.suite.user;
22link this.suite.path_params = { userId: id };
23link }
Provides the full context of the test (spec). Modify its properties on a before_*
hook to change the spec request.
💡 Chain requests by utilizing data previously saved to
this.suite
to modify the spec.
Available in:
before_each
after_each
before_test
after_test
1link - name: get user
2link request:
3link path: /user
4link method: get
5link before_test:
6link run_type: module
7link module:
8link function: !!js/function >
9link function () {
10link this.suite.user = JSON.parse(this.response.body);
11link }
12link - name: get addresses
13link request:
14link path: /users/{userId}/addresses
15link method: get
16link after_test:
17link run_type: module
18link module:
19link function: !!js/function >
20link function () {
21link const { id } = this.suite.user;
22link this.suite.path_params = { userId: id };
23link }
Provides full information about the response of this spec.
Available in:
after_each
after_test
1link - name: get user
2link request:
3link path: /user
4link method: get
5link before_test:
6link run_type: module
7link module:
8link function: !!js/function >
9link function () {
10link this.suite.user = JSON.parse(this.response.body);
11link }