@schwabyio/gta 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/SPEC.md +1354 -0
- package/dist/THIRD_PARTY_NOTICES.txt +71 -0
- package/dist/chunks/chunk-VRAFYQNE.js +58985 -0
- package/dist/gta.js +1703 -0
- package/dist/worker.js +10 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 schwabyio
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# gta
|
|
2
|
+
|
|
3
|
+
The command-line runner of Gravity Test Automation. Tests for HTTP APIs are plain YAML
|
|
4
|
+
files that live in your repository beside the code they test, and read and diff as text
|
|
5
|
+
in a pull request. `gta` runs them from a terminal or in CI, and writes JUnit, HTML and
|
|
6
|
+
JSON reports. Gravity, the desktop app, edits and runs the same files on the same engine.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
You need Node.js 22.12 or later.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install -g @schwabyio/gta
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or add it to a project's `package.json`, and run it there with `npx gta`:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install --save-dev @schwabyio/gta
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The package has no dependencies to install: everything `gta` uses is bundled into it.
|
|
23
|
+
|
|
24
|
+
## A first project
|
|
25
|
+
|
|
26
|
+
A project is a folder holding a `collections/` directory, an `environments/` one and a
|
|
27
|
+
`settings.yml`. The smallest project `gta` runs is three files:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
# collections/health.yml
|
|
31
|
+
id: health
|
|
32
|
+
steps:
|
|
33
|
+
- name: service is up
|
|
34
|
+
GET: '{{baseUrl}}/health'
|
|
35
|
+
tests: |
|
|
36
|
+
gta.expectResponseStatusCodeToBe(200)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
# environments/local.yml
|
|
41
|
+
vars:
|
|
42
|
+
baseUrl: http://localhost:8080
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
# settings.yml: how gta runs the project
|
|
47
|
+
environmentType: local
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then, from the project folder:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
gta all
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Collections
|
|
57
|
+
|
|
58
|
+
A collection is a list of requests, called steps. They run in order, and a later step can
|
|
59
|
+
use a value an earlier one saved, like `sessionId` here:
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
# collections/checkout.yml
|
|
63
|
+
id: checkout
|
|
64
|
+
headers:
|
|
65
|
+
Authorization: 'Bearer {{apiKey}}'
|
|
66
|
+
steps:
|
|
67
|
+
- name: create session
|
|
68
|
+
POST: '{{baseUrl}}/sessions'
|
|
69
|
+
body:
|
|
70
|
+
json: |
|
|
71
|
+
{ "amount": 1200 }
|
|
72
|
+
tests: |
|
|
73
|
+
gta.expectResponseStatusCodeToBe(201)
|
|
74
|
+
gta.expectResponseBodyToHaveProperty('id', 'sessionId', 'setAsCollectionVariable')
|
|
75
|
+
|
|
76
|
+
- name: read it back
|
|
77
|
+
GET: '{{baseUrl}}/sessions/{{sessionId}}'
|
|
78
|
+
tests: |
|
|
79
|
+
gta.expectResponseStatusCodeToBe(200)
|
|
80
|
+
gta.expectResponseBodyToHaveProperty('amount', 1200)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
An environment supplies the variables for one target. A secret's value is never written
|
|
84
|
+
in a file: it comes from the process environment variable of the same name, or from a
|
|
85
|
+
`.env` file that is not committed.
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
# environments/staging.yml
|
|
89
|
+
vars:
|
|
90
|
+
baseUrl: https://staging.example.com
|
|
91
|
+
apiKey: { secret: true }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Running
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
gta get # list what gta all would run
|
|
98
|
+
gta all # run every collection
|
|
99
|
+
gta smoke,checkout # run these collections, in this order
|
|
100
|
+
gta payments # run every collection in collections/payments/
|
|
101
|
+
gta all --tags smoke --generateJUnitResults
|
|
102
|
+
gta all --environmentType staging --limitConcurrency 8
|
|
103
|
+
gta all --json # print the results as JSON instead of the table
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Collections run in parallel up to `limitConcurrency`, each in a worker thread of its own.
|
|
107
|
+
The steps within a collection always run in order.
|
|
108
|
+
|
|
109
|
+
The exit code is `0` when everything passed, `1` when something failed, and `2` when
|
|
110
|
+
`gta` could not run at all, such as with a bad setting or an unknown collection.
|
|
111
|
+
|
|
112
|
+
## Settings
|
|
113
|
+
|
|
114
|
+
Settings come from `settings.yml`, then `GTA_*` environment variables, then flags on the
|
|
115
|
+
command line, each overriding the one before. An unknown setting is an error.
|
|
116
|
+
`gta --help` lists them all:
|
|
117
|
+
|
|
118
|
+
| Setting | Default | What it does |
|
|
119
|
+
| ------------------------ | -------------- | -------------------------------------------------------------- |
|
|
120
|
+
| `environmentType` | none | The environment to run against: `environments/<name>.yml` |
|
|
121
|
+
| `limitConcurrency` | `1` | How many collections run at once |
|
|
122
|
+
| `timeoutCollection` | `3600000` | Milliseconds a collection may take before it is stopped |
|
|
123
|
+
| `bail` | `false` | Stop a collection at its first failing step |
|
|
124
|
+
| `tags` | none | Run only what has one of these tags |
|
|
125
|
+
| `notTags` | none | Leave out what has one of these tags |
|
|
126
|
+
| `generateJUnitResults` | `false` | Write `<testResultsBasePath>/junit/junit.xml` |
|
|
127
|
+
| `generateJsonResults` | `false` | Write `<testResultsBasePath>/json/results.json` |
|
|
128
|
+
| `generateHtmlResults` | `false` | Write `<testResultsBasePath>/html/`, a summary and a page each |
|
|
129
|
+
| `autoOpenTestResultHtml` | `false` | Write the HTML report and open it when the run ends |
|
|
130
|
+
| `testResultsBasePath` | `test-results` | Where reports go: relative to the project folder, or absolute |
|
|
131
|
+
|
|
132
|
+
The results folder is emptied before every run, so everything in it is from the last one.
|
|
133
|
+
`gta` only ever deletes a folder that holds nothing but its own reports.
|
|
134
|
+
|
|
135
|
+
## In CI
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
# .github/workflows/api-tests.yml (steps)
|
|
139
|
+
- uses: actions/setup-node@v4
|
|
140
|
+
with:
|
|
141
|
+
node-version: 22
|
|
142
|
+
- run: npm install -g @schwabyio/gta
|
|
143
|
+
- run: gta all --environmentType staging --generateJUnitResults
|
|
144
|
+
env:
|
|
145
|
+
apiKey: ${{ secrets.STAGING_API_KEY }}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## The file format
|
|
149
|
+
|
|
150
|
+
[SPEC.md](https://github.com/schwabyio/gravity/blob/main/SPEC.md) specifies every file,
|
|
151
|
+
every key, and every rule that makes a file invalid. It is written for people and coding
|
|
152
|
+
agents alike, and ends with a complete project to start from. It also ships in this
|
|
153
|
+
package as `dist/SPEC.md`, and `gta`'s messages cite its sections, as in "(SPEC.md §2.5)".
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT. The packages bundled into `gta` keep their own licenses, collected in
|
|
158
|
+
`dist/THIRD_PARTY_NOTICES.txt`.
|