@schwabyio/gta 0.10.0 → 0.12.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/README.md +8 -3
- package/dist/SPEC.md +71 -27
- package/dist/chunks/{chunk-MZSHHPAQ.js → chunk-3NSHWS24.js} +453 -335
- package/dist/gta.js +69 -31
- package/dist/worker.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,14 +108,14 @@ The steps within a collection always run in order.
|
|
|
108
108
|
|
|
109
109
|
The exit code is `0` when everything passed, `1` when something failed, and `2` when
|
|
110
110
|
`gta` could not run at all, such as with a bad setting or an unknown collection.
|
|
111
|
-
`gta get` exits `1` when a collection is broken, or has a `use
|
|
112
|
-
would stop at.
|
|
111
|
+
`gta get` exits `1` when a collection is broken, or has a `use:`, an `extends:` or a
|
|
112
|
+
file its body sends that a run would stop at.
|
|
113
113
|
|
|
114
114
|
## Settings
|
|
115
115
|
|
|
116
116
|
Settings come from `settings.yml`, then `GTA_*` environment variables, then flags on the
|
|
117
117
|
command line, each overriding the one before. An unknown setting is an error.
|
|
118
|
-
`gta --help` lists them all:
|
|
118
|
+
`gta --help` lists them all, and `gta get` shows where each one came from:
|
|
119
119
|
|
|
120
120
|
| Setting | Default | What it does |
|
|
121
121
|
| ------------------------ | -------------- | -------------------------------------------------------------- |
|
|
@@ -134,6 +134,11 @@ command line, each overriding the one before. An unknown setting is an error.
|
|
|
134
134
|
The results folder is emptied before every run, so everything in it is from the last one.
|
|
135
135
|
`gta` only ever deletes a folder that holds nothing but its own reports.
|
|
136
136
|
|
|
137
|
+
In a monorepo, projects that share a global project (`uses:` in `project.yml`) share its
|
|
138
|
+
`settings.yml` too. It comes before the project's own, so a project changes a shared
|
|
139
|
+
setting by setting it again in its own file. Each project still needs a `settings.yml`,
|
|
140
|
+
even an empty one.
|
|
141
|
+
|
|
137
142
|
## In CI
|
|
138
143
|
|
|
139
144
|
```yaml
|
package/dist/SPEC.md
CHANGED
|
@@ -152,16 +152,16 @@ tls:
|
|
|
152
152
|
|
|
153
153
|
The file is optional, and so is every key in it. Any other key is an error.
|
|
154
154
|
|
|
155
|
-
| Key | Type | Default | Meaning
|
|
156
|
-
| -------- | ---------------------- | ----------- |
|
|
157
|
-
| `name` | string | folder name | Display name.
|
|
158
|
-
| `uses` | string (relative path) | none | A global project whose
|
|
159
|
-
| `vars` | map of plain values | none | Variables for every collection in the project (§4).
|
|
160
|
-
| `tls.ca` | list of relative paths | none | Certificate files that requests trust (below).
|
|
155
|
+
| Key | Type | Default | Meaning |
|
|
156
|
+
| -------- | ---------------------- | ----------- | ----------------------------------------------------- |
|
|
157
|
+
| `name` | string | folder name | Display name. |
|
|
158
|
+
| `uses` | string (relative path) | none | A global project whose files this one shares (below). |
|
|
159
|
+
| `vars` | map of plain values | none | Variables for every collection in the project (§4). |
|
|
160
|
+
| `tls.ca` | list of relative paths | none | Certificate files that requests trust (below). |
|
|
161
161
|
|
|
162
162
|
**`uses`** names a **global project**: an ordinary project whose `project.yml`
|
|
163
|
-
variables, `environments/`, `requests/`, `endpoints/`, `bases
|
|
164
|
-
project using it shares.
|
|
163
|
+
variables, `environments/`, `requests/`, `endpoints/`, `bases/`, `checks/` and
|
|
164
|
+
`settings.yml` every project using it shares.
|
|
165
165
|
|
|
166
166
|
- It must be a relative path. An absolute path is refused, since it would only work on
|
|
167
167
|
one machine. Write it with `/`; `\` reads the same.
|
|
@@ -170,6 +170,7 @@ project using it shares.
|
|
|
170
170
|
- An environment in the global project merges under the project's environment of the
|
|
171
171
|
same name, key by key, and the project's values win. An environment only the global
|
|
172
172
|
project has is available too.
|
|
173
|
+
- The global project's `settings.yml` lies under the project's the same way (§1.3).
|
|
173
174
|
|
|
174
175
|
**`tls.ca`** lists certificate files that requests trust, for a server whose certificate
|
|
175
176
|
a company or local CA signed, or a server's own self-signed certificate. A request
|
|
@@ -212,8 +213,9 @@ Projects are shared between macOS, Windows and Linux, and read the same on all t
|
|
|
212
213
|
without an extension. A file with such a name, made on macOS or Linux, is reported.
|
|
213
214
|
- Files should use LF line endings. Gravity writes LF, and can add a `.gitattributes`
|
|
214
215
|
scoped to the project's own files so that git keeps them LF on every platform. The same
|
|
215
|
-
block keeps `files/` exactly as committed, so a body sends the same bytes everywhere.
|
|
216
|
-
|
|
216
|
+
block keeps `files/` exactly as committed, so a body sends the same bytes everywhere. A
|
|
217
|
+
global project is a project too: its own block covers its `files/`. For files a body
|
|
218
|
+
sends from another folder, add a `-text` line of your own.
|
|
217
219
|
- The process environment is read by exact name on every platform, although Windows
|
|
218
220
|
itself ignores case (§4, §6).
|
|
219
221
|
|
|
@@ -257,9 +259,22 @@ The results folder is emptied before every run. `gta` refuses to empty one that
|
|
|
257
259
|
files it did not write, or one that holds the project itself. Every report replaces
|
|
258
260
|
each secret's value with `[secret: NAME]` (§6).
|
|
259
261
|
|
|
262
|
+
**From the global project.** A global project (§1.1) can have a `settings.yml` too.
|
|
263
|
+
Every project that `uses` it runs with those settings under its own: a key the
|
|
264
|
+
project's file sets wins, and a key it leaves out comes from the global project's file.
|
|
265
|
+
|
|
266
|
+
- There is no switch to turn this off. A project undoes a shared setting by setting it
|
|
267
|
+
in its own file, back to the default if need be: `environmentType: null`, `tags: []`.
|
|
268
|
+
- A project still needs a `settings.yml` of its own, even an empty one. A global project
|
|
269
|
+
need not have one.
|
|
270
|
+
- A relative `testResultsBasePath` is relative to the project being run, whichever file
|
|
271
|
+
set it.
|
|
272
|
+
|
|
260
273
|
**Overrides.** Each setting can be overridden by an environment variable, then by a
|
|
261
274
|
command-line flag: `GTA_LIMIT_CONCURRENCY=8`, then `--limitConcurrency 8`. A list is
|
|
262
|
-
comma-separated: `--tags smoke,api`.
|
|
275
|
+
comma-separated: `--tags smoke,api`. In all, from lowest to highest: the default, the
|
|
276
|
+
global project's `settings.yml`, the project's, the environment variable, the flag.
|
|
277
|
+
`gta get` lists each setting that is not a default, and where it came from.
|
|
263
278
|
|
|
264
279
|
**Running.** `gta` runs from the project folder:
|
|
265
280
|
|
|
@@ -269,9 +284,11 @@ comma-separated: `--tags smoke,api`.
|
|
|
269
284
|
| `gta all` | Every collection, except those with `exclude: true` (§2.4). |
|
|
270
285
|
| `gta smoke,checkout/` | The collections and directories named, in that order. |
|
|
271
286
|
|
|
272
|
-
`gta get` also reports each `use:` and `extends:` that would stop a run,
|
|
273
|
-
|
|
274
|
-
|
|
287
|
+
`gta get` also reports each `use:` and `extends:` that would stop a run, and each file a
|
|
288
|
+
body names that is in neither the project nor its global project (§2.2), in every
|
|
289
|
+
collection, including those `gta all` leaves out (Appendix A). A file path with
|
|
290
|
+
`{{variables}}` is left to the run. It exits `1` when it finds one, or a broken
|
|
291
|
+
collection, and `0` otherwise.
|
|
275
292
|
|
|
276
293
|
A collection is named by its `id`, or by its place (`checkout/sessions`). A directory is
|
|
277
294
|
named by its name, and `checkout/` names only the directory. `--flag name=value` sets a
|
|
@@ -487,13 +504,28 @@ the project the step belongs to. For a step of a request set, that is the set's
|
|
|
487
504
|
project, which may be a global one. The path is the same wherever the collection sits
|
|
488
505
|
inside `collections/`.
|
|
489
506
|
|
|
507
|
+
A file that is not there is looked for in the global project (§1.1), as a request set
|
|
508
|
+
or a base collection is, so projects can share one copy of a file. A project's own file
|
|
509
|
+
of the same path wins. `global:` before the path reads only the global project's:
|
|
510
|
+
|
|
511
|
+
```yaml
|
|
512
|
+
body:
|
|
513
|
+
multipart:
|
|
514
|
+
avatar: { file: files/test-png.png } # the project's, else the global project's
|
|
515
|
+
terms: { file: global:files/terms.pdf } # the global project's only
|
|
516
|
+
```
|
|
517
|
+
|
|
490
518
|
- It must be a relative path, written with `/`. An absolute path is refused.
|
|
519
|
+
- A path out of the project folder, such as `../other/files/a.png`, is read from where
|
|
520
|
+
it points, with no global project to fall back to. A `global:` path stays inside the
|
|
521
|
+
global project folder, and is an error in a project that uses none.
|
|
491
522
|
- `{{variables}}` resolve in the path, so a data file row (§2.8) can choose the file.
|
|
492
523
|
- A file is sent byte for byte. `{{…}}` inside it is not a variable.
|
|
493
524
|
- A file that cannot be read stops the step before anything is sent, in its own `body`
|
|
494
|
-
phase, naming the file.
|
|
525
|
+
phase, naming the file and each place it was looked for.
|
|
495
526
|
- Where a request is shown (results, reports, `req.body`), a file's bytes appear as
|
|
496
|
-
`‹file files/avatar.png, 1234 bytes
|
|
527
|
+
`‹file files/avatar.png, 1234 bytes›`, and a global project's file as
|
|
528
|
+
`‹file global:files/terms.pdf, 5254 bytes›`, however the step named it.
|
|
497
529
|
|
|
498
530
|
### 2.3 `settings` and `headers`
|
|
499
531
|
|
|
@@ -610,8 +642,8 @@ steps:
|
|
|
610
642
|
values. No variable can take the place of a `params.` name.
|
|
611
643
|
|
|
612
644
|
A default may name variables and other params, as in
|
|
613
|
-
`email: '{{params.accountId}}@example.com'`. Like a `with:` value, it is resolved once
|
|
614
|
-
|
|
645
|
+
`email: '{{params.accountId}}@example.com'`. Like a `with:` value, it is resolved once
|
|
646
|
+
for each use, so `accountId: '{{$uuid}}'` is one id wherever the set reads it.
|
|
615
647
|
|
|
616
648
|
**A use step** holds only `use`, `with`, `name`, `tags`, `flags`, `docs` and `tests`. A
|
|
617
649
|
method key, `headers`, `body`, `settings` or `before` on it is an error, and `with`
|
|
@@ -621,9 +653,11 @@ without `use` is an error too.
|
|
|
621
653
|
global project. `use: auth/login` is one directory down. `use: global:login` looks
|
|
622
654
|
only in the global project.
|
|
623
655
|
- **`with:`** gives plain values; a param left out takes its default. A string may hold
|
|
624
|
-
`{{variables}}`, resolved
|
|
625
|
-
|
|
626
|
-
|
|
656
|
+
`{{variables}}`, resolved as the set's first request starts, just after the
|
|
657
|
+
collection's `before.script` has run for it: a value that script sets for each step
|
|
658
|
+
(§4) reaches the set. A missing required value, a name the set does not take, or a
|
|
659
|
+
value or default that cannot be resolved stops the set's steps before anything is
|
|
660
|
+
sent.
|
|
627
661
|
- **Running.** A use step runs each of the set's steps in turn, in the collection's
|
|
628
662
|
variable scope, so what one sets the next can read, and so can the steps after the use
|
|
629
663
|
step. Each request is reported as its own result. When the use step has a `name`,
|
|
@@ -632,7 +666,10 @@ without `use` is an error too.
|
|
|
632
666
|
- **Layers.** Headers and settings: the collection's, under the set's, under each
|
|
633
667
|
step's own. Scripts run collection, then set, then step: `before.script` before the
|
|
634
668
|
request and `tests` after. The use step's own `tests` run last, on the response of
|
|
635
|
-
the set's step marked `useTests: true`, or else its last step.
|
|
669
|
+
the set's step marked `useTests: true`, or else its last step. `params` is the set's
|
|
670
|
+
alone: the collection's scripts, and a base collection's or an endpoint's (§2.6,
|
|
671
|
+
§2.7), never see it. In an endpoint's `before.script`, a segment written as
|
|
672
|
+
`{{params.id}}` reads as written.
|
|
636
673
|
- **One level.** A request set must not `use:` another, and has `params`, not `vars`. A
|
|
637
674
|
file in `requests/` without `params` is not a request set.
|
|
638
675
|
|
|
@@ -1148,6 +1185,10 @@ There is nothing to load, and no `startXTest` or `endXTest`.
|
|
|
1148
1185
|
| `gta.randomInt(min, max)`: a whole number, both ends included | ✓ |
|
|
1149
1186
|
| `gta.date(format, secondsOffset = 0, timeZone = 'local')` | ✓ |
|
|
1150
1187
|
|
|
1188
|
+
`gta.set` keeps a string, number, boolean or null as it is, and stores an object or array
|
|
1189
|
+
as JSON text. `undefined` is stored as `null`, so a variable set to nothing still reads
|
|
1190
|
+
`== null`, and `{{name}}` resolves as a null does (§4).
|
|
1191
|
+
|
|
1151
1192
|
Calling a response check in `before.script` is an error, and so is `gta.skip` in
|
|
1152
1193
|
`tests`, where the request has been sent. After `gta.skip` the script runs to its end,
|
|
1153
1194
|
and no later `before.script` runs. `gta.skipRest` skips steps of this row only: the next
|
|
@@ -1256,7 +1297,8 @@ global project's root.
|
|
|
1256
1297
|
|
|
1257
1298
|
- A secret with no value anywhere fails the run, naming it. An empty credential is never
|
|
1258
1299
|
sent.
|
|
1259
|
-
- Reports replace a secret's value with `[secret: NAME]`, wherever it appears.
|
|
1300
|
+
- Reports replace a secret's value with `[secret: NAME]`, wherever it appears. So does
|
|
1301
|
+
the desktop app where it shows a request as sent.
|
|
1260
1302
|
- `.env` holds `NAME=value` lines. `#` starts a comment line, `export ` before a name is
|
|
1261
1303
|
allowed, and a value may be quoted. It must not be committed.
|
|
1262
1304
|
|
|
@@ -1372,8 +1414,8 @@ it. Rules checked at run time fail the step, or the run, before anything is sent
|
|
|
1372
1414
|
- `uses` and `tls.ca` entries are relative paths.
|
|
1373
1415
|
- The folder `uses` names has a `project.yml`, and does not itself `uses` another.
|
|
1374
1416
|
- Each `tls.ca` file exists and holds a PEM or DER certificate.
|
|
1375
|
-
- `settings.yml` exists for `gta
|
|
1376
|
-
environment that exists.
|
|
1417
|
+
- `settings.yml` exists for `gta`; a global project's is optional. The `environmentType`
|
|
1418
|
+
a run ends up with, if any, names an environment that exists.
|
|
1377
1419
|
|
|
1378
1420
|
**At run time**
|
|
1379
1421
|
|
|
@@ -1382,9 +1424,11 @@ it. Rules checked at run time fail the step, or the run, before anything is sent
|
|
|
1382
1424
|
- Every feature flag named is known to the run.
|
|
1383
1425
|
- The flag `command`, if any, has every quote closed, starts, and exits `0` within 60
|
|
1384
1426
|
seconds, printing a JSON object.
|
|
1385
|
-
- Every file a body names can be read from the project folder
|
|
1427
|
+
- Every file a body names can be read from the project folder, or its global
|
|
1428
|
+
project's (§2.2).
|
|
1386
1429
|
- Every `use:` and `extends:` names a usable file, and every `with:` suits its set.
|
|
1387
|
-
`gta get` checks these without
|
|
1430
|
+
`gta get` checks these, and the body files named without `{{variables}}`, without
|
|
1431
|
+
running anything (§1.3).
|
|
1388
1432
|
- A step's `forEach` resolves to a JSON array.
|
|
1389
1433
|
- In `{{@name}}`, `name` holds text naming a variable that exists.
|
|
1390
1434
|
- A `before.script` sets `req.body` to text, and only for a `json`, `xml`, `text` or
|