Skip to content

Commit a917ac6

Browse files
authored
Merge pull request #4 from jordanpowell88/fix-cypress-ct-qwik
feat(cypress-ct-qwik): add 3rd party support
2 parents 8c70392 + fb0bfe8 commit a917ac6

File tree

14 files changed

+2156
-2156
lines changed

14 files changed

+2156
-2156
lines changed

.all-contributorsrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
"review",
2525
"ideas"
2626
]
27+
},
28+
{
29+
"login": "jordanpowell88",
30+
"name": "Jordan Powell",
31+
"avatar_url": "https://avatars.githubusercontent.com/u/3605268?v=4",
32+
"profile": "https://github.com/jordanpowell88",
33+
"contributions": [
34+
"code",
35+
"test",
36+
"infra",
37+
"review",
38+
"ideas"
39+
]
2740
}
2841
],
2942
"contributorsPerLine": 7,

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ runs:
4141

4242
- name: Install dependencies
4343
shell: bash
44-
run: pnpm install --frozen-lockfile
44+
run: pnpm install --frozen-lockfile --config.auto-install-peers=false

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
save-exact = true
1+
save-exact = true
2+
auto-install-peers=false

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,46 @@ npm install -D cypress-ct-qwik
4343

4444
## Configuring Cypress
4545

46+
1. Run cypress (in watch mode) after installation
47+
2. Follow the configuration wizard
48+
3. Add `addQwikLoader` to the `component.ts` file -
49+
4650
```ts
47-
// cypress.config.ts
51+
// component.ts
4852

49-
import { defineConfig } from 'cypress';
53+
import { addQwikLoader } from 'cypress-ct-qwik';
5054

51-
export default defineConfig({
52-
component: {
53-
devServer: {
54-
mode: 'test',
55-
bundler: 'vite',
56-
} as any,
57-
},
58-
});
55+
addQwikLoader();
5956
```
6057

61-
Add `addQwikLoader` to the `component.ts` file -
58+
4. Add the `mount` command to `support/commands.ts` -
6259

6360
```ts
64-
// component.ts
61+
// commands.ts
6562

66-
import { addQwikLoader } from 'cypress-ct-qwik';
63+
import { mount } from 'cypress-ct-qwik';
6764

68-
addQwikLoader();
65+
declare namespace Cypress {
66+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
67+
interface Chainable<Subject> {
68+
mount: typeof mount;
69+
}
70+
}
71+
//
72+
73+
Cypress.Commands.add('mount', mount);
6974
```
7075

7176
## Usage
7277

7378
```ts
7479
// some-test.cy.ts
7580

76-
import { mount } from 'cypress-ct-qwik';
7781
import MyComp from './my-comp';
7882

7983
describe(`Qwik Component Test`, () => {
8084
it('should find my link', () => {
81-
mount(<MyComp />);
85+
cy.mount(<MyComp />);
8286

8387
cy.contains('myLink').should('exist');
8488
});

apps/qwik-app/cypress.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
import { defineConfig } from 'cypress';
1+
import { defineConfig } from "cypress";
22

3-
export default defineConfig({});
3+
export default defineConfig({
4+
component: {
5+
devServer: {
6+
framework: "cypress-ct-qwik",
7+
bundler: "vite",
8+
},
9+
},
10+
});

apps/qwik-app/cypress/support/commands.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/// <reference types="cypress" />
2+
3+
import { mount } from "cypress-ct-qwik";
4+
25
// ***********************************************
36
// This example commands.ts shows you how to
47
// create various custom commands and overwrite
@@ -14,13 +17,16 @@ declare namespace Cypress {
1417
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1518
interface Chainable<Subject> {
1619
login(email: string, password: string): void;
20+
mount: typeof mount
1721
}
1822
}
1923
//
2024
// -- This is a parent command --
2125
Cypress.Commands.add('login', (email, password) => {
2226
console.log('Custom command example: Login', email, password);
2327
});
28+
29+
Cypress.Commands.add('mount', mount)
2430
//
2531
// -- This is a child command --
2632
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })

apps/qwik-app/src/components/header/header.cy.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { mount } from 'cypress-ct-qwik';
21
import Header from './header';
32

43
describe(`header component test`, () => {
54
it('should find a link', () => {
6-
mount(<Header />);
5+
cy.mount(<Header />);
76

87
cy.contains(/docs/i).should('exist');
98
});
109

1110
it('should click on a button', () => {
12-
mount(<Header />);
11+
cy.mount(<Header />);
1312

1413
cy.contains(/opened/i).should('not.exist');
1514
cy.contains(/click me/i).click();

packages/cypress-ct-qwik/definition.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { defineComponentFramework } from 'cypress';
22

33
const qwik: Cypress.CypressComponentDependency = {
4-
type: 'cypress-ct-qwik',
4+
type: 'qwik',
55
name: 'Qwik',
66
package: '@builder.io/qwik',
77
installer: '@builder.io/qwik',
88
description: 'The HTML-first framework',
9-
minVersion: '^0.19.2',
9+
minVersion: '>0.19.2',
1010
};
1111

1212
const qwikCity: Cypress.CypressComponentDependency = {
13-
type: 'cypress-ct-qwik',
13+
type: 'qwik-ct',
1414
name: 'Qwik City',
1515
package: '@builder.io/qwik-city',
1616
installer: '@builder.io/qwik-city',
1717
description: 'The meta-framework for Qwik',
18-
minVersion: '^0.4.0',
18+
minVersion: '>0.4.0',
1919
};
2020

2121
export default defineComponentFramework({
@@ -54,4 +54,18 @@ export default defineComponentFramework({
5454
dependencies: (bundler) => {
5555
return [qwik, qwikCity];
5656
},
57+
58+
icon: `<svg style="height: auto; width: 100%" viewBox="0 0 52 60"
59+
fill="none" xmlns="http://www.w3.org/2000/svg">
60+
61+
<path
62+
d="M40.973 52.5351L32.0861 43.6985L31.9503 43.7179V43.621L13.0511 24.9595L17.708 20.4637L14.9721 4.76715L1.99103 20.8513C-0.220992 23.0798 -0.628467 26.7036 0.962635 29.3778L9.07337 42.8265C10.3152 44.9 12.566 46.1402 14.9915 46.1208L19.0081 46.082L40.973 52.5351Z"
63+
fill="#18B6F6" />
64+
<path
65+
d="M45.8232 20.5411L44.038 17.2468L43.1066 15.5609L42.738 14.902L42.6992 14.9408L37.8094 6.47238C36.587 4.34075 34.2974 3.02301 31.8137 3.04239L27.5255 3.15865L14.7384 3.19741C12.313 3.21679 10.101 4.49577 8.87853 6.56927L1.09766 21.9945L15.0101 4.72831L33.2496 24.7656L30.0091 28.0406L31.9495 43.7178L31.9689 43.679V43.7178H31.9301L31.9689 43.7565L33.4824 45.2293L40.8364 52.4187C41.1469 52.7094 41.6514 52.3606 41.4379 51.9924L36.8975 43.0589L44.8142 28.4282L45.0664 28.1375C45.1634 28.0212 45.2604 27.905 45.3381 27.7887C46.8904 25.6764 47.1038 22.8472 45.8232 20.5411Z"
66+
fill="#AC7EF4" />
67+
<path
68+
d="M33.3076 24.6882L15.0099 4.74774L17.61 20.3668L12.9531 24.882L31.9105 43.6985L30.203 28.0794L33.3076 24.6882Z"
69+
fill="white" />
70+
</svg>`
5771
});
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
{
22
"name": "cypress-ct-qwik",
33
"version": "0.0.6",
4-
"type": "module",
54
"exports": {
6-
"node": "definition.js",
7-
"require": "definition.js",
5+
"node": "./definition.js",
86
"default": "./src/index.js"
97
},
8+
"files": [
9+
"package.json",
10+
"definition.js",
11+
"definition.d.ts",
12+
"src/index.js",
13+
"src/index.d.ts",
14+
"src/lib"
15+
],
1016
"dependencies": {
1117
"@cypress/mount-utils": "^4.0.0"
1218
},
1319
"peerDependencies": {
14-
"cypress": ">=10.6.0",
15-
"@builder.io/qwik": "^0.16.0"
20+
"cypress": ">=12.8.1",
21+
"@builder.io/qwik": ">0.23.0"
1622
}
1723
}

packages/cypress-ct-qwik/project.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"sourceRoot": "packages/cypress-ct-qwik/src",
55
"projectType": "library",
66
"targets": {
7-
"build": {
8-
"dependsOn": ["build-definition"],
7+
"build-mount": {
98
"executor": "@nrwl/js:tsc",
109
"outputs": ["{options.outputPath}"],
1110
"options": {
1211
"outputPath": "dist/packages/cypress-ct-qwik",
1312
"main": "packages/cypress-ct-qwik/src/index.ts",
1413
"tsConfig": "packages/cypress-ct-qwik/tsconfig.lib.json",
14+
"clean": false,
1515

1616
"assets": [
1717
"README.md",
@@ -32,9 +32,26 @@
3232
"options": {
3333
"outputPath": "dist/packages/cypress-ct-qwik",
3434
"main": "packages/cypress-ct-qwik/definition.ts",
35-
"tsConfig": "packages/cypress-ct-qwik/tsconfig.definition.json"
35+
"tsConfig": "packages/cypress-ct-qwik/tsconfig.definition.json",
36+
"clean": false
37+
}
38+
},
39+
"copy": {
40+
"executor": "nx:run-commands",
41+
"options": {
42+
"command": "cp -r dist/packages/cypress-ct-qwik node_modules"
3643
}
3744
},
45+
"build": {
46+
"executor": "nx:run-commands",
47+
"options": {
48+
"commands": [
49+
"nx run cypress-ct-qwik:build-mount --skip-nx-cache && nx run cypress-ct-qwik:build-definition --skip-nx-cache"
50+
]
51+
},
52+
"outputPath": "node_modules/cypress-ct-qwik",
53+
"outputs": ["{options.outputPath}"]
54+
},
3855
"lint": {
3956
"executor": "@nrwl/linter:eslint",
4057
"outputs": ["{options.outputFile}"],

0 commit comments

Comments
 (0)