UNPKG

cumulocity-cypress

Version:
78 lines (61 loc) 2.83 kB
# [0.9.0](https://github.com/Cumulocity-IoT/cumulocity-cypress/compare/v0.8.14...v0.9.0) (2025-05-26) ### Bug Fixes * **c8ypact:** Add regexReplace config option for preprocessor ([#417](https://github.com/Cumulocity-IoT/cumulocity-cypress/issues/417)) ([980a5cf](https://github.com/Cumulocity-IoT/cumulocity-cypress/commit/980a5cfdd3b01780a4079f12fbee152ec3ce64eb)) ### Features * **c8ypact:** Allow loading yaml and js files using C8yPactDefaultFileAdapter ([#418](https://github.com/Cumulocity-IoT/cumulocity-cypress/issues/418)) ([0a1b5e4](https://github.com/Cumulocity-IoT/cumulocity-cypress/commit/0a1b5e4754223cae064cbcac246a71aa647cd8ba)) `C8yPactDefaultFileAdapter` now supports `yaml` as well as `(c)js` loading of `C8yPact` files. Using Javascript is useful if you are using `C8yPact` files for API testing to dynamically create records and reduce duplication required in `json`. To enable Javascript, `C8yPactDefaultFileAdapter` requires the `enableJavaScript` config option to be enabled. By default, Javascript support is disabled. ```typescript import { defineConfig } from 'cypress'; import { configureC8yPlugin } from 'cumulocity-cypress/plugin'; module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { const adapter = new C8yPactDefaultFileAdapter("/my/custom/pact/location", { enableJavaScript: true, }); configureC8yPlugin(on, config, { pactAdapter: adapter, }); return config; }, }, }); ``` * **c8ypact:** Allow use of $ref references in C8yPact documents ([#421](https://github.com/Cumulocity-IoT/cumulocity-cypress/issues/421)) ([07fc822](https://github.com/Cumulocity-IoT/cumulocity-cypress/commit/07fc8226f586adcf21bdc5ecaa671deca95db064)) Use `$ref` for referencing json objects defined within the same or external json document. This allows reuse of json objects in C8yPact documents. References can be parameterized, supporting simple json placeholders of format `{{ name }}` in the referenced json object. Parameters must be added as key / value pair to the reference using format `?key1=value1&key2=value2`. Use `Int()`, `Bool()` and `Float()` to convert parameter values to the given type. Example use. ```json { "definitions": { "body": { "message": "Hello {{name}}!", "details": { "value": "The value is {{value}}.", "status": "{{status}}", } } }, "records": [ { "request": { "method": "POST", "url": "/params" }, "response": { "status": 201, "body": { "$ref": "#/definitions/body?name=World&value=42&&status=Int(10)" } } } ], } ``` To reference external documents use ```json { "body": { "$ref": "relative/path/to/definitions.json#/body?name=Galaxy&value=Int(123)", }, } ```