slicetest 0.8.0 → 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/dist/yaml.js CHANGED
@@ -20,8 +20,8 @@ const KINDS = {
20
20
  use: ["with"],
21
21
  };
22
22
  const EXPECT_KEYS = {
23
- request: ["status", "statuses", "headers", "json", "text", "queries", "schema"],
24
- submit: ["status", "headers", "json", "text", "schema"],
23
+ request: ["status", "statuses", "headers", "json", "text", "queries", "schema", "duration", "cookies", "events"],
24
+ submit: ["status", "headers", "json", "text", "schema", "duration", "cookies", "events"],
25
25
  sql: ["rows", "count"],
26
26
  db: ["rows", "count"],
27
27
  };
@@ -275,6 +275,18 @@ function parseStep(node, fail, lineOf) {
275
275
  };
276
276
  if (raw.within !== undefined && (typeof raw.within !== "number" || raw.within <= 0))
277
277
  fail(at("within"), "`within` must be a positive number of milliseconds");
278
+ const events = raw.expect?.events;
279
+ if (events !== undefined && !(Array.isArray(events) && events.every((e) => e && typeof e === "object" && !Array.isArray(e)))) {
280
+ fail(at("expect"), "`expect.events` is a list of events, each a subset of { event, data, id }: [{ event: message_stop }]");
281
+ }
282
+ const cookies = raw.expect?.cookies;
283
+ if (cookies !== undefined && (!cookies || typeof cookies !== "object" || Array.isArray(cookies) || Object.values(cookies).some((c) => c !== null && (typeof c !== "object" || Array.isArray(c))))) {
284
+ fail(at("expect"), "`expect.cookies` maps cookie names to attributes ({ sid: { httpOnly: true } }), {} for any value, or null for a cookie that must not be set");
285
+ }
286
+ const duration = raw.expect?.duration;
287
+ if (duration !== undefined && !((typeof duration === "number" && duration > 0) || (duration && typeof duration === "object" && !Array.isArray(duration)))) {
288
+ fail(at("expect"), "`expect.duration` is a number of milliseconds (at most), or a matcher such as { $lt: 200 }");
289
+ }
278
290
  const number = (key) => {
279
291
  if (raw[key] !== undefined && (typeof raw[key] !== "number" || raw[key] < 0))
280
292
  fail(at(key), `\`${key}\` must be a non-negative number`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicetest",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Framework-agnostic slice tests: drive a real app process over HTTP with a real Postgres, MySQL or SQLite and stubbed outbound APIs, checked against OpenAPI contracts.",
5
5
  "keywords": [
6
6
  "testing",
@@ -656,10 +656,18 @@
656
656
  "additionalProperties": false,
657
657
  "properties": {
658
658
  "status": {
659
+ "description": "A code (201), a class (\"2xx\") or a list of them ([200, 204]).",
659
660
  "type": [
660
661
  "integer",
661
- "string"
662
- ]
662
+ "string",
663
+ "array"
664
+ ],
665
+ "items": {
666
+ "type": [
667
+ "integer",
668
+ "string"
669
+ ]
670
+ }
663
671
  },
664
672
  "headers": {
665
673
  "type": "object"
@@ -668,6 +676,31 @@
668
676
  "description": "Subset of the response JSON"
669
677
  },
670
678
  "text": {},
679
+ "events": {
680
+ "type": "array",
681
+ "items": {
682
+ "type": "object"
683
+ },
684
+ "description": "Server-sent events of a text/event-stream response that must come in this order, others allowed between: [{ event: message_start }, { data: \"[DONE]\" }]. Each is a subset of { event, data, id }"
685
+ },
686
+ "cookies": {
687
+ "type": "object",
688
+ "description": "Cookies the response sets, by name: attributes as a subset ({ httpOnly: true, sameSite: Lax, value: ... }), or null for one it must not set",
689
+ "additionalProperties": {
690
+ "type": [
691
+ "object",
692
+ "null"
693
+ ]
694
+ }
695
+ },
696
+ "duration": {
697
+ "description": "The response arrived within this many milliseconds, or a matcher on the time: { $lt: 200 }",
698
+ "type": [
699
+ "integer",
700
+ "object"
701
+ ],
702
+ "minimum": 1
703
+ },
671
704
  "statuses": {
672
705
  "type": "object",
673
706
  "propertyNames": {
@@ -899,10 +932,18 @@
899
932
  "additionalProperties": false,
900
933
  "properties": {
901
934
  "status": {
935
+ "description": "A code (201), a class (\"2xx\") or a list of them ([200, 204]).",
902
936
  "type": [
903
937
  "integer",
904
- "string"
905
- ]
938
+ "string",
939
+ "array"
940
+ ],
941
+ "items": {
942
+ "type": [
943
+ "integer",
944
+ "string"
945
+ ]
946
+ }
906
947
  },
907
948
  "headers": {
908
949
  "type": "object"
@@ -911,6 +952,31 @@
911
952
  "description": "Subset of the response JSON"
912
953
  },
913
954
  "text": {},
955
+ "events": {
956
+ "type": "array",
957
+ "items": {
958
+ "type": "object"
959
+ },
960
+ "description": "Server-sent events of a text/event-stream response that must come in this order, others allowed between: [{ event: message_start }, { data: \"[DONE]\" }]. Each is a subset of { event, data, id }"
961
+ },
962
+ "cookies": {
963
+ "type": "object",
964
+ "description": "Cookies the response sets, by name: attributes as a subset ({ httpOnly: true, sameSite: Lax, value: ... }), or null for one it must not set",
965
+ "additionalProperties": {
966
+ "type": [
967
+ "object",
968
+ "null"
969
+ ]
970
+ }
971
+ },
972
+ "duration": {
973
+ "description": "The response arrived within this many milliseconds, or a matcher on the time: { $lt: 200 }",
974
+ "type": [
975
+ "integer",
976
+ "object"
977
+ ],
978
+ "minimum": 1
979
+ },
914
980
  "schema": {
915
981
  "description": "A JSON Schema the response JSON must match: inline, or a file relative to this one with an optional pointer, e.g. ../openapi.yaml#/components/schemas/Poll",
916
982
  "oneOf": [