cypress-ct-octane-js 0.1.32 → 0.1.34
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 +46 -4
- package/dist/index.js +8 -5
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<
|
|
1
|
+
<a href="https://octanejs.dev/">Octane</a> framework definition and mount adapter for <a href="https://docs.cypress.io/app/component-testing/">component testing</a> with <a href="https://www.cypress.io/">Cypress</a>
|
|
2
2
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
@@ -20,13 +20,55 @@ pnpm add cypress-ct-octane-js
|
|
|
20
20
|
npm cypress-ct-octane-js
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
Add `cypress-ct-octane-js` framework to your `cypress.config.{ts,js}` file
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
component: {
|
|
30
|
+
devServer: {
|
|
31
|
+
framework: "cypress-ct-octane-js",
|
|
32
|
+
bundler: "vite",
|
|
33
|
+
//...more config if necessary
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you use Typescript, you may get a type error when setting the framework property. To fix it, type cast the property to `any` like this:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
framework: 'cypress-ct-octane-js' as any,
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Adding mount command
|
|
46
|
+
|
|
47
|
+
Add the following lines to your `component.ts` in the `cypress` directory.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { mount } from "cypress-ct-octane-js";
|
|
51
|
+
|
|
52
|
+
declare global {
|
|
53
|
+
namespace Cypress {
|
|
54
|
+
interface Chainable {
|
|
55
|
+
mount: typeof mount;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Cypress.Commands.add("mount", mount);
|
|
61
|
+
```
|
|
62
|
+
|
|
23
63
|
## Usage example
|
|
24
64
|
|
|
65
|
+
You can now use the `cy.mount` function to mount octane components in Cypress.
|
|
66
|
+
|
|
25
67
|
```javascript
|
|
26
|
-
import {
|
|
68
|
+
import { Greeting } from "my-octane-components";
|
|
27
69
|
|
|
28
|
-
it("
|
|
29
|
-
mount(
|
|
70
|
+
it("should display 'Hello World'", () => {
|
|
71
|
+
cy.mount(<Greeting text="Hello World!" />);
|
|
30
72
|
cy.contains("Hello World!").should("be.visible");
|
|
31
73
|
});
|
|
32
74
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { getContainerEl, setupHooks } from "@cypress/mount-utils";
|
|
2
2
|
import { createRoot } from "octane";
|
|
3
|
+
let isLogEnabled = false;
|
|
3
4
|
let dispose;
|
|
4
5
|
function cleanup() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (isLogEnabled !== false) {
|
|
7
|
+
Cypress.log({
|
|
8
|
+
name: "unmount",
|
|
9
|
+
message: "Unmounted component",
|
|
10
|
+
});
|
|
11
|
+
}
|
|
9
12
|
dispose === null || dispose === void 0 ? void 0 : dispose();
|
|
10
13
|
}
|
|
11
14
|
export function mount(component, options = {}) {
|
|
15
|
+
isLogEnabled = options.log;
|
|
12
16
|
const container = getContainerEl();
|
|
13
17
|
if (!container) {
|
|
14
18
|
throw new Error("'root' element not found");
|
|
15
19
|
}
|
|
16
|
-
console.log(container.innerHTML);
|
|
17
20
|
const root = createRoot(container);
|
|
18
21
|
dispose = root.unmount;
|
|
19
22
|
root.render(component);
|
package/package.json
CHANGED