@wdio/cli 8.6.1 → 8.6.3
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/build/constants.d.ts +10 -4
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +7 -3
- package/build/templates/exampleFiles/browser/Component.css.ejs +120 -0
- package/build/templates/exampleFiles/browser/Component.lit.ejs +128 -0
- package/build/templates/exampleFiles/browser/Component.lit.test.ejs +22 -0
- package/build/templates/exampleFiles/browser/Component.preact.ejs +28 -0
- package/build/templates/exampleFiles/browser/Component.preact.test.ejs +57 -0
- package/build/templates/exampleFiles/browser/Component.react.ejs +29 -0
- package/build/templates/exampleFiles/browser/Component.react.test.ejs +55 -0
- package/build/templates/exampleFiles/browser/Component.solid.ejs +28 -0
- package/build/templates/exampleFiles/browser/Component.solid.test.ejs +55 -0
- package/build/templates/exampleFiles/browser/Component.svelte.ejs +47 -0
- package/build/templates/exampleFiles/browser/Component.svelte.test.ejs +55 -0
- package/build/templates/exampleFiles/browser/Component.vue.ejs +34 -0
- package/build/templates/exampleFiles/browser/Component.vue.test.ejs +59 -0
- package/build/templates/exampleFiles/browser/standalone.test.ejs +13 -0
- package/build/templates/exampleFiles/mocha/example.e2e.js.ejs +0 -76
- package/build/templates/wdio.conf.tpl.ejs +3 -1
- package/build/utils.d.ts +1 -0
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +40 -0
- package/package.json +5 -5
package/build/constants.d.ts
CHANGED
|
@@ -239,10 +239,13 @@ export declare const SUPPORTED_PACKAGES: {
|
|
|
239
239
|
readonly value: "wdio-vitaqai-service$--$vitaqai";
|
|
240
240
|
}];
|
|
241
241
|
};
|
|
242
|
-
export declare const SUPPORTED_BROWSER_RUNNER_PRESETS: {
|
|
242
|
+
export declare const SUPPORTED_BROWSER_RUNNER_PRESETS: ({
|
|
243
243
|
name: string;
|
|
244
244
|
value: string;
|
|
245
|
-
}
|
|
245
|
+
} | {
|
|
246
|
+
name: string;
|
|
247
|
+
value: boolean;
|
|
248
|
+
})[];
|
|
246
249
|
export declare const TESTING_LIBRARY_PACKAGES: Record<string, string>;
|
|
247
250
|
export declare const BACKEND_CHOICES: readonly ["On my local machine", "In the cloud using Experitest", "In the cloud using Sauce Labs", "In the cloud using BrowserStack", "In the cloud using Testingbot or LambdaTest or a different service", "I have my own Selenium cloud"];
|
|
248
251
|
export declare const PROTOCOL_OPTIONS: readonly ["https", "http"];
|
|
@@ -266,10 +269,13 @@ export declare const QUESTIONNAIRE: ({
|
|
|
266
269
|
type: string;
|
|
267
270
|
name: string;
|
|
268
271
|
message: string;
|
|
269
|
-
choices: {
|
|
272
|
+
choices: ({
|
|
270
273
|
name: string;
|
|
271
274
|
value: string;
|
|
272
|
-
}
|
|
275
|
+
} | {
|
|
276
|
+
name: string;
|
|
277
|
+
value: boolean;
|
|
278
|
+
})[];
|
|
273
279
|
when: typeof isBrowserRunner;
|
|
274
280
|
default?: undefined;
|
|
275
281
|
validate?: undefined;
|
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAG9C,eAAO,MAAM,GAAG,KAA6B,CAAA;AAE7C,eAAO,MAAM,YAAY,QAAqE,CAAA;AAE9F,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAA;AAED,eAAO,MAAM,mBAAmB,8HAI/B,CAAA;AAED,eAAO,MAAM,6BAA6B,8cAYzC,CAAA;AAED,eAAO,MAAM,iCAAiC,8CAG7C,CAAA;AAED,eAAO,MAAM,WAAW,KAAK,CAAA;AAE7B,eAAO,MAAM,cAAc;;;;CAI1B,CAAA;AAED,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,iGAI1B,CAAA;AAEV,eAAO,MAAM,gBAAgB;;;;CAInB,CAAA;AAE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|
148
148
|
{ name: 'React (https://reactjs.org/)', value: '@vitejs/plugin-react$--$react' },
|
|
149
149
|
{ name: 'Preact (https://preactjs.com/)', value: '@preact/preset-vite$--$preact' },
|
|
150
|
-
{ name: 'Other', value:
|
|
150
|
+
{ name: 'Other', value: false }
|
|
151
151
|
];
|
|
152
152
|
export const TESTING_LIBRARY_PACKAGES = {
|
|
153
153
|
react: '@testing-library/react',
|
|
154
154
|
preact: '@testing-library/preact',
|
|
155
155
|
vue: '@testing-library/vue',
|
|
156
|
-
svelte: '@testing-library/svelte'
|
|
156
|
+
svelte: '@testing-library/svelte',
|
|
157
|
+
solid: 'solid-testing-library'
|
|
157
158
|
};
|
|
158
159
|
export const BACKEND_CHOICES = [
|
|
159
160
|
'On my local machine',
|
|
@@ -342,7 +343,10 @@ export const QUESTIONNAIRE = [{
|
|
|
342
343
|
type: 'input',
|
|
343
344
|
name: 'specs',
|
|
344
345
|
message: 'Where should these files be located?',
|
|
345
|
-
default: /* istanbul ignore next */ (answers) =>
|
|
346
|
+
default: /* istanbul ignore next */ (answers) => {
|
|
347
|
+
const pattern = isBrowserRunner(answers) ? 'src/**/*.test' : 'test/specs/**/*';
|
|
348
|
+
return getDefaultFiles(answers, pattern);
|
|
349
|
+
},
|
|
346
350
|
when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.framework.match(/(mocha|jasmine)/)
|
|
347
351
|
}, {
|
|
348
352
|
type: 'input',
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
font-size: 16px;
|
|
4
|
+
line-height: 24px;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
|
|
7
|
+
color-scheme: light dark;
|
|
8
|
+
color: rgba(255, 255, 255, 0.87);
|
|
9
|
+
background-color: #242424;
|
|
10
|
+
|
|
11
|
+
font-synthesis: none;
|
|
12
|
+
text-rendering: optimizeLegibility;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
-webkit-text-size-adjust: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
a {
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
color: #EA5906;
|
|
21
|
+
text-decoration: inherit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
a:hover {
|
|
25
|
+
color: #EA5906;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body {
|
|
29
|
+
margin: 0;
|
|
30
|
+
display: flex;
|
|
31
|
+
place-items: center;
|
|
32
|
+
min-width: 320px;
|
|
33
|
+
min-height: 100vh;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
h1 {
|
|
37
|
+
font-size: 3.2em;
|
|
38
|
+
line-height: 1.1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
button {
|
|
42
|
+
border-radius: 8px;
|
|
43
|
+
border: 1px solid transparent;
|
|
44
|
+
padding: 0.6em 1.2em;
|
|
45
|
+
font-size: 1em;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
font-family: inherit;
|
|
48
|
+
background-color: #1a1a1a;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
transition: border-color 0.25s;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
button:hover {
|
|
54
|
+
border-color: #EA5906;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
button:focus,
|
|
58
|
+
button:focus-visible {
|
|
59
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (prefers-color-scheme: light) {
|
|
63
|
+
:root {
|
|
64
|
+
color: #213547;
|
|
65
|
+
background-color: #ffffff;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
a:hover {
|
|
69
|
+
color: #EA590633;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
button {
|
|
73
|
+
background-color: #f9f9f9;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#root {
|
|
78
|
+
max-width: 1280px;
|
|
79
|
+
margin: 0 auto;
|
|
80
|
+
padding: 2rem;
|
|
81
|
+
text-align: center;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.logo {
|
|
85
|
+
height: 12em;
|
|
86
|
+
padding: 1.5em;
|
|
87
|
+
will-change: filter;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.logo:hover {
|
|
91
|
+
filter: drop-shadow(0 0 2em #EA5906aa);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.logo.react:hover {
|
|
95
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@keyframes logo-spin {
|
|
99
|
+
from {
|
|
100
|
+
transform: rotate(0deg);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
to {
|
|
104
|
+
transform: rotate(360deg);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
109
|
+
a:nth-of-type(2) .logo {
|
|
110
|
+
animation: logo-spin infinite 20s linear;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.card {
|
|
115
|
+
padding: 2em;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.read-the-docs {
|
|
119
|
+
color: #888;
|
|
120
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit'
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An example element.
|
|
6
|
+
*
|
|
7
|
+
* @slot - This element has a slot
|
|
8
|
+
* @csspart button - The button
|
|
9
|
+
*/
|
|
10
|
+
@customElement('my-element')
|
|
11
|
+
export class MyElement extends LitElement {
|
|
12
|
+
/**
|
|
13
|
+
* Copy for the read the docs hint.
|
|
14
|
+
*/
|
|
15
|
+
@property()
|
|
16
|
+
docsHint = 'Click on the Vite and Lit logos to learn more'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The number of times the button has been clicked.
|
|
20
|
+
*/
|
|
21
|
+
@property({ type: Number })
|
|
22
|
+
count = 0
|
|
23
|
+
|
|
24
|
+
render() {
|
|
25
|
+
return html`
|
|
26
|
+
<div>
|
|
27
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
28
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo"
|
|
29
|
+
alt="WebdriverIO logo" />
|
|
30
|
+
</a>
|
|
31
|
+
</div>
|
|
32
|
+
<h1>
|
|
33
|
+
<slot></slot>
|
|
34
|
+
</h1>
|
|
35
|
+
<div class="card">
|
|
36
|
+
<button @click=${this._onClick} part="button">
|
|
37
|
+
count is ${this.count}
|
|
38
|
+
</button>
|
|
39
|
+
<p>
|
|
40
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
41
|
+
</p>
|
|
42
|
+
</div>
|
|
43
|
+
<p class="read-the-docs">${this.docsHint}</p>
|
|
44
|
+
`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private _onClick() {
|
|
48
|
+
this.count++
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static styles = css`
|
|
52
|
+
:host {
|
|
53
|
+
max-width: 1280px;
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
padding: 2rem;
|
|
56
|
+
text-align: center;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.logo {
|
|
60
|
+
height: 6em;
|
|
61
|
+
padding: 1.5em;
|
|
62
|
+
will-change: filter;
|
|
63
|
+
transition: filter 300ms;
|
|
64
|
+
}
|
|
65
|
+
.logo:hover {
|
|
66
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
67
|
+
}
|
|
68
|
+
.logo.lit:hover {
|
|
69
|
+
filter: drop-shadow(0 0 2em #325cffaa);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.card {
|
|
73
|
+
padding: 2em;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.read-the-docs {
|
|
77
|
+
color: #888;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
h1 {
|
|
81
|
+
font-size: 3.2em;
|
|
82
|
+
line-height: 1.1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
a {
|
|
86
|
+
font-weight: 500;
|
|
87
|
+
color: #646cff;
|
|
88
|
+
text-decoration: inherit;
|
|
89
|
+
}
|
|
90
|
+
a:hover {
|
|
91
|
+
color: #535bf2;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
button {
|
|
95
|
+
border-radius: 8px;
|
|
96
|
+
border: 1px solid transparent;
|
|
97
|
+
padding: 0.6em 1.2em;
|
|
98
|
+
font-size: 1em;
|
|
99
|
+
font-weight: 500;
|
|
100
|
+
font-family: inherit;
|
|
101
|
+
background-color: #1a1a1a;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
transition: border-color 0.25s;
|
|
104
|
+
}
|
|
105
|
+
button:hover {
|
|
106
|
+
border-color: #646cff;
|
|
107
|
+
}
|
|
108
|
+
button:focus,
|
|
109
|
+
button:focus-visible {
|
|
110
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@media (prefers-color-scheme: light) {
|
|
114
|
+
a:hover {
|
|
115
|
+
color: #747bff;
|
|
116
|
+
}
|
|
117
|
+
button {
|
|
118
|
+
background-color: #f9f9f9;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare global {
|
|
125
|
+
interface HTMLElementTagNameMap {
|
|
126
|
+
'my-element': MyElement
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { html, render } from 'lit'
|
|
2
|
+
import { $, expect } from '@wdio/globals'
|
|
3
|
+
|
|
4
|
+
import './Component.lit.js'
|
|
5
|
+
import './Component.css'
|
|
6
|
+
|
|
7
|
+
describe('Lit component testing', () => {
|
|
8
|
+
it('should increment value on click', async () => {
|
|
9
|
+
render(
|
|
10
|
+
html`<my-element id="root">WebdriverIO Component Testing</my-element>`,
|
|
11
|
+
document.body
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const button = await $('my-element').$('>>>button')
|
|
15
|
+
await expect(button).toHaveText('count is 0')
|
|
16
|
+
|
|
17
|
+
await button.click()
|
|
18
|
+
await button.click()
|
|
19
|
+
|
|
20
|
+
await expect(button).toHaveText('count is 2')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useState } from 'preact/hooks'
|
|
2
|
+
import './Component.css'
|
|
3
|
+
|
|
4
|
+
export function App() {
|
|
5
|
+
const [count, setCount] = useState(0)
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<div>
|
|
10
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
11
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo" alt="WebdriverIO logo" />
|
|
12
|
+
</a>
|
|
13
|
+
</div>
|
|
14
|
+
<h1>WebdriverIO Component Testing</h1>
|
|
15
|
+
<div class="card">
|
|
16
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
17
|
+
count is {count}
|
|
18
|
+
</button>
|
|
19
|
+
<p>
|
|
20
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
21
|
+
</p>
|
|
22
|
+
</div>
|
|
23
|
+
<p class="read-the-docs">
|
|
24
|
+
Click on the Vite and Preact logos to learn more
|
|
25
|
+
</p>
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const harnessImport = installTestingLibrary
|
|
3
|
+
? `import { h } from 'preact'\nimport { render, screen, fireEvent } from '@testing-library/preact'`
|
|
4
|
+
: `import { render, h } from 'preact'\nimport htm from 'https://esm.sh/htm'`
|
|
5
|
+
const renderCommand = installTestingLibrary
|
|
6
|
+
? `render(<ExampleComponent />)`
|
|
7
|
+
: `const root = createRoot(container)
|
|
8
|
+
root.render(<ExampleComponent />)`
|
|
9
|
+
%>
|
|
10
|
+
import { expect, $ } from '@wdio/globals'
|
|
11
|
+
<%- harnessImport %>
|
|
12
|
+
<% if (installTestingLibrary) { %>
|
|
13
|
+
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
14
|
+
expect.extend(matchers)
|
|
15
|
+
<% } else { %>
|
|
16
|
+
// Initialize htm with Preact
|
|
17
|
+
const html = htm.bind(h);
|
|
18
|
+
<% } %>
|
|
19
|
+
import ExampleComponent from './Component.js'
|
|
20
|
+
|
|
21
|
+
describe('Preact Component Tests', () => {
|
|
22
|
+
<% if (installTestingLibrary) { %>
|
|
23
|
+
it('should test component with Testing Library', async () => {
|
|
24
|
+
render(<ExampleComponent />)
|
|
25
|
+
const component = screen.getByText(/count is 0/i)
|
|
26
|
+
expect(component).toBeInTheDocument()
|
|
27
|
+
|
|
28
|
+
await fireEvent.click(component)
|
|
29
|
+
await fireEvent.click(component)
|
|
30
|
+
|
|
31
|
+
expect(screen.getByText(/count is 2/i)).toBeInTheDocument()
|
|
32
|
+
})
|
|
33
|
+
<% } else { %>
|
|
34
|
+
let container: Element
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
container = document.createElement('div')
|
|
38
|
+
document.body.appendChild(container)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
container?.remove()
|
|
43
|
+
})
|
|
44
|
+
<% } %>
|
|
45
|
+
|
|
46
|
+
it('should test component with WebdriverIO', async () => {
|
|
47
|
+
<%- renderCommand %>
|
|
48
|
+
|
|
49
|
+
const component = await $('button=count is 0')
|
|
50
|
+
await expect(component).toBePresent()
|
|
51
|
+
|
|
52
|
+
await component.click()
|
|
53
|
+
await component.click()
|
|
54
|
+
|
|
55
|
+
await expect($('button=count is 2')).toBePresent()
|
|
56
|
+
})
|
|
57
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import './Component.css'
|
|
4
|
+
|
|
5
|
+
export default function ExampleComponent () {
|
|
6
|
+
const [count, setCount] = useState(0)
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<div id="root">
|
|
10
|
+
<div>
|
|
11
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
12
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo" alt="WebdriverIO logo" />
|
|
13
|
+
</a>
|
|
14
|
+
</div>
|
|
15
|
+
<h1>WebdriverIO Component Testing</h1>
|
|
16
|
+
<div className="card">
|
|
17
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
18
|
+
count is {count}
|
|
19
|
+
</button>
|
|
20
|
+
<p>
|
|
21
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
24
|
+
<p className="read-the-docs">
|
|
25
|
+
Click on the WebdriverIO logo to learn more
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const harnessImport = installTestingLibrary
|
|
3
|
+
? `import { render, screen, fireEvent } from '@testing-library/react'`
|
|
4
|
+
: `import { createRoot } from 'react-dom/client'`
|
|
5
|
+
const renderCommand = installTestingLibrary
|
|
6
|
+
? `render(<ExampleComponent />)`
|
|
7
|
+
: `const root = createRoot(container)
|
|
8
|
+
root.render(<ExampleComponent />)`
|
|
9
|
+
%>
|
|
10
|
+
import React from 'react'
|
|
11
|
+
import { expect, $ } from '@wdio/globals'
|
|
12
|
+
<%- harnessImport %>
|
|
13
|
+
<% if (installTestingLibrary) { %>
|
|
14
|
+
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
15
|
+
expect.extend(matchers)
|
|
16
|
+
<% } %>
|
|
17
|
+
import ExampleComponent from './Component.js'
|
|
18
|
+
|
|
19
|
+
describe('React Component Tests', () => {
|
|
20
|
+
<% if (installTestingLibrary) { %>
|
|
21
|
+
it('should test component with Testing Library', async () => {
|
|
22
|
+
render(<ExampleComponent />)
|
|
23
|
+
const component = screen.getByText(/count is 0/i)
|
|
24
|
+
expect(component).toBeInTheDocument()
|
|
25
|
+
|
|
26
|
+
await fireEvent.click(component)
|
|
27
|
+
await fireEvent.click(component)
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText(/count is 2/i)).toBeInTheDocument()
|
|
30
|
+
})
|
|
31
|
+
<% } else { %>
|
|
32
|
+
let container: Element
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
container = document.createElement('div')
|
|
36
|
+
document.body.appendChild(container)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
container?.remove()
|
|
41
|
+
})
|
|
42
|
+
<% } %>
|
|
43
|
+
|
|
44
|
+
it('should test component with WebdriverIO', async () => {
|
|
45
|
+
<%- renderCommand %>
|
|
46
|
+
|
|
47
|
+
const component = await $('button=count is 0')
|
|
48
|
+
await expect(component).toBePresent()
|
|
49
|
+
|
|
50
|
+
await component.click()
|
|
51
|
+
await component.click()
|
|
52
|
+
|
|
53
|
+
await expect($('button=count is 2')).toBePresent()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSignal } from 'solidjs'
|
|
2
|
+
import './Component.css'
|
|
3
|
+
|
|
4
|
+
export function App() {
|
|
5
|
+
const [count, setCount] = createSignal(0)
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<div>
|
|
10
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
11
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo" alt="WebdriverIO logo" />
|
|
12
|
+
</a>
|
|
13
|
+
</div>
|
|
14
|
+
<h1>WebdriverIO Component Testing</h1>
|
|
15
|
+
<div class="card">
|
|
16
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
17
|
+
count is {count}
|
|
18
|
+
</button>
|
|
19
|
+
<p>
|
|
20
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
21
|
+
</p>
|
|
22
|
+
</div>
|
|
23
|
+
<p class="read-the-docs">
|
|
24
|
+
Click on the Vite and Preact logos to learn more
|
|
25
|
+
</p>
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const harnessImport = installTestingLibrary
|
|
3
|
+
? `import { cleanup, render, screen } from 'solid-testing-library'`
|
|
4
|
+
: `import { render } from 'solid-js/web'`
|
|
5
|
+
const renderCommand = installTestingLibrary
|
|
6
|
+
? `render(() => <ExampleComponent />)`
|
|
7
|
+
: `render(<ExampleComponent />, container)`
|
|
8
|
+
%>
|
|
9
|
+
import { expect, $ } from '@wdio/globals'
|
|
10
|
+
<%- harnessImport %>
|
|
11
|
+
<% if (installTestingLibrary) { %>
|
|
12
|
+
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
13
|
+
expect.extend(matchers)
|
|
14
|
+
<% } %>
|
|
15
|
+
import ExampleComponent from './Component.js'
|
|
16
|
+
|
|
17
|
+
describe('Preact Component Tests', () => {
|
|
18
|
+
<% if (installTestingLibrary) { %>
|
|
19
|
+
afterEach(cleanup)
|
|
20
|
+
|
|
21
|
+
it('should test component with Testing Library', async () => {
|
|
22
|
+
render(() => <ExampleComponent />)
|
|
23
|
+
const component = screen.getByText(/count is 0/i)
|
|
24
|
+
expect(component).toBeInTheDocument()
|
|
25
|
+
|
|
26
|
+
await fireEvent.click(component)
|
|
27
|
+
await fireEvent.click(component)
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText(/count is 2/i)).toBeInTheDocument()
|
|
30
|
+
})
|
|
31
|
+
<% } else { %>
|
|
32
|
+
let container: Element
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
container = document.createElement('div')
|
|
36
|
+
document.body.appendChild(container)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
container?.remove()
|
|
41
|
+
})
|
|
42
|
+
<% } %>
|
|
43
|
+
|
|
44
|
+
it('should test component with WebdriverIO', async () => {
|
|
45
|
+
<%- renderCommand %>
|
|
46
|
+
|
|
47
|
+
const component = await $('button=count is 0')
|
|
48
|
+
await expect(component).toBePresent()
|
|
49
|
+
|
|
50
|
+
await component.click()
|
|
51
|
+
await component.click()
|
|
52
|
+
|
|
53
|
+
await expect($('button=count is 2')).toBePresent()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let count = 0
|
|
3
|
+
const increment = () => {
|
|
4
|
+
count += 1
|
|
5
|
+
}
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<main id="root">
|
|
9
|
+
<div>
|
|
10
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
11
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo"
|
|
12
|
+
alt="WebdriverIO logo" />
|
|
13
|
+
</a>
|
|
14
|
+
</div>
|
|
15
|
+
<h1>WebdriverIO Component Testing</h1>
|
|
16
|
+
|
|
17
|
+
<div class="card">
|
|
18
|
+
<button on:click={increment}>
|
|
19
|
+
count is {count}
|
|
20
|
+
</button>
|
|
21
|
+
<p>
|
|
22
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<p class="read-the-docs">
|
|
27
|
+
Click on the Vite and Svelte logos to learn more
|
|
28
|
+
</p>
|
|
29
|
+
</main>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.logo {
|
|
33
|
+
height: 6em;
|
|
34
|
+
padding: 1.5em;
|
|
35
|
+
will-change: filter;
|
|
36
|
+
transition: filter 300ms;
|
|
37
|
+
}
|
|
38
|
+
.logo:hover {
|
|
39
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
40
|
+
}
|
|
41
|
+
.logo.svelte:hover {
|
|
42
|
+
filter: drop-shadow(0 0 2em #ff3e00aa);
|
|
43
|
+
}
|
|
44
|
+
.read-the-docs {
|
|
45
|
+
color: #888;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const harnessImport = installTestingLibrary
|
|
3
|
+
? `import { render, fireEvent } from '@testing-library/svelte'`
|
|
4
|
+
: ``
|
|
5
|
+
const renderCommand = installTestingLibrary
|
|
6
|
+
? `render(ExampleComponent)`
|
|
7
|
+
: `new ExampleComponent({ target: container, props: {} })`
|
|
8
|
+
%>
|
|
9
|
+
import { $, expect } from '@wdio/globals'
|
|
10
|
+
<%- harnessImport %>
|
|
11
|
+
<% if (installTestingLibrary) { %>
|
|
12
|
+
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
13
|
+
expect.extend(matchers)
|
|
14
|
+
<% } %>
|
|
15
|
+
import ExampleComponent from './Component.svelte'
|
|
16
|
+
import './Component.css'
|
|
17
|
+
|
|
18
|
+
describe('Svelte Component Testing', () => {
|
|
19
|
+
<% if (installTestingLibrary) { %>
|
|
20
|
+
it('should test component with Testing Library', async () => {
|
|
21
|
+
const { getByText } = render(ExampleComponent)
|
|
22
|
+
|
|
23
|
+
const component = getByText(/count is 0/i)
|
|
24
|
+
expect(component).toBeInTheDocument()
|
|
25
|
+
|
|
26
|
+
await fireEvent.click(component)
|
|
27
|
+
await fireEvent.click(component)
|
|
28
|
+
|
|
29
|
+
expect(getByText(/count is 2/i)).toBeInTheDocument()
|
|
30
|
+
})
|
|
31
|
+
<% } else { %>
|
|
32
|
+
let container: Element
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
container = document.createElement('div')
|
|
36
|
+
document.body.appendChild(container)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
container?.remove()
|
|
41
|
+
})
|
|
42
|
+
<% } %>
|
|
43
|
+
|
|
44
|
+
it('should test component with WebdriverIO', async () => {
|
|
45
|
+
<%- renderCommand %>
|
|
46
|
+
|
|
47
|
+
const component = await $('button=count is 0')
|
|
48
|
+
await expect(component).toBePresent()
|
|
49
|
+
|
|
50
|
+
await component.click()
|
|
51
|
+
await component.click()
|
|
52
|
+
|
|
53
|
+
await expect($('button=count is 2')).toBePresent()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineProps<{ msg: string }>()
|
|
5
|
+
|
|
6
|
+
const count = ref(0)
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div id="root">
|
|
11
|
+
<div>
|
|
12
|
+
<a href="https://webdriver.io/docs/component-testing" target="_blank">
|
|
13
|
+
<img src="https://webdriver.io/assets/images/robot-3677788dd63849c56aa5cb3f332b12d5.svg" className="logo"
|
|
14
|
+
alt="WebdriverIO logo" />
|
|
15
|
+
</a>
|
|
16
|
+
</div>
|
|
17
|
+
<h1>{{ msg }}</h1>
|
|
18
|
+
|
|
19
|
+
<div class="card">
|
|
20
|
+
<button type="button" @click="count++">count is {{ count }}</button>
|
|
21
|
+
<p>
|
|
22
|
+
Edit <code>src/Component.test.tsx</code> and save to test HMR
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<p class="read-the-docs">Click on the WebdriverIO logo to learn more</p>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<style scoped>
|
|
31
|
+
.read-the-docs {
|
|
32
|
+
color: #888;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<%
|
|
2
|
+
const harnessImport = installTestingLibrary
|
|
3
|
+
? `import { render, fireEvent } from '@testing-library/vue'`
|
|
4
|
+
: `import { createApp } from 'vue'`
|
|
5
|
+
const renderCommand = installTestingLibrary
|
|
6
|
+
? `render(ExampleComponent, { props: { msg: 'WebdriverIO Component Testing' } })`
|
|
7
|
+
: `createApp(ExampleComponent, { msg: 'WebdriverIO Component Testing' }).mount(container)`
|
|
8
|
+
%>
|
|
9
|
+
import { $, expect } from '@wdio/globals'
|
|
10
|
+
<%- harnessImport %>
|
|
11
|
+
<% if (installTestingLibrary) { %>
|
|
12
|
+
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
13
|
+
expect.extend(matchers)
|
|
14
|
+
<% } %>
|
|
15
|
+
import ExampleComponent from './Component.vue.ejs'
|
|
16
|
+
import './Component.css'
|
|
17
|
+
|
|
18
|
+
describe('Vue Component Testing', () => {
|
|
19
|
+
<% if (installTestingLibrary) { %>
|
|
20
|
+
it('should test component with Testing Library', async () => {
|
|
21
|
+
// The render method returns a collection of utilities to query your component.
|
|
22
|
+
const { getByText } = render(ExampleComponent, {
|
|
23
|
+
props: { msg: 'WebdriverIO Component Testing' }
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const component = getByText(/count is 0/i)
|
|
27
|
+
expect(component).toBeInTheDocument()
|
|
28
|
+
|
|
29
|
+
await fireEvent.click(component)
|
|
30
|
+
await fireEvent.click(component)
|
|
31
|
+
|
|
32
|
+
expect(getByText(/count is 2/i)).toBeInTheDocument()
|
|
33
|
+
})
|
|
34
|
+
<% } else { %>
|
|
35
|
+
let container: Element
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
container = document.createElement('div')
|
|
39
|
+
container.setAttribute('id', 'app')
|
|
40
|
+
document.body.appendChild(container)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
container?.remove()
|
|
45
|
+
})
|
|
46
|
+
<% } %>
|
|
47
|
+
|
|
48
|
+
it('should test component with WebdriverIO', async () => {
|
|
49
|
+
<%- renderCommand %>
|
|
50
|
+
|
|
51
|
+
const component = await $('button=count is 0')
|
|
52
|
+
await expect(component).toBePresent()
|
|
53
|
+
|
|
54
|
+
await component.click()
|
|
55
|
+
await component.click()
|
|
56
|
+
|
|
57
|
+
await expect($('button=count is 2')).toBePresent()
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { $, expect } from '@wdio/globals'
|
|
2
|
+
|
|
3
|
+
describe('WebdriverIO Component Testing', () => {
|
|
4
|
+
it('should be able to render to the DOM and assert', async () => {
|
|
5
|
+
const component = document.createElement('button')
|
|
6
|
+
component.innerHTML = 'Hello World!'
|
|
7
|
+
document.body.appendChild(component)
|
|
8
|
+
|
|
9
|
+
await expect($('aria/Hello World!')).toBePresent()
|
|
10
|
+
component.remove()
|
|
11
|
+
await expect($('aria/Hello World!')).not.toBePresent()
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -21,82 +21,6 @@ describe('My Login application', () => {
|
|
|
21
21
|
})
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
<% } else if (runner === 'browser') {
|
|
25
|
-
|
|
26
|
-
const componentSuffix = preset
|
|
27
|
-
? ['svelte', 'vue'].includes(preset)
|
|
28
|
-
? preset
|
|
29
|
-
: isUsingTypeScript ? 'tsx' : 'jsx'
|
|
30
|
-
: isUsingTypeScript ? 'ts' : 'js'
|
|
31
|
-
const importStatement = preset
|
|
32
|
-
? `import Component from '/path/to/component.${componentSuffix}'`
|
|
33
|
-
: `import '/path/to/component.${componentSuffix}'`
|
|
34
|
-
const renderStatement = (preset
|
|
35
|
-
? installTestingLibrary
|
|
36
|
-
? [
|
|
37
|
-
preset.includes('react')
|
|
38
|
-
? 'render(<Component />)'
|
|
39
|
-
: 'render(Component, { prop: \'foobar\' })',
|
|
40
|
-
'const component = screen.getByText(/Click me!/i)'
|
|
41
|
-
]
|
|
42
|
-
: preset === 'solid'
|
|
43
|
-
? [
|
|
44
|
-
'render(() => <Component />, ref)',
|
|
45
|
-
'const component = \'.someSelector\''
|
|
46
|
-
]
|
|
47
|
-
: [
|
|
48
|
-
'// render component here...',
|
|
49
|
-
'const component = document.querySelector("my-component")'
|
|
50
|
-
]
|
|
51
|
-
: [
|
|
52
|
-
`const component = document.createElement('example-component')`,
|
|
53
|
-
`component.setAttribute('prop', 'foobar')`,
|
|
54
|
-
`document.body.appendChild(component)`
|
|
55
|
-
]
|
|
56
|
-
).join('\n ')
|
|
57
|
-
const assertionStatement = preset && installTestingLibrary
|
|
58
|
-
? `expect(component).toContainText('Click me!')`
|
|
59
|
-
: `await expect(elem).toHaveText('Click me!')`
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Component Testing
|
|
63
|
-
*/
|
|
64
|
-
%>import { expect, $ } from '@wdio/globals'
|
|
65
|
-
<%- installTestingLibrary
|
|
66
|
-
? `import { render, screen } from '@testing-library/${preset}'`
|
|
67
|
-
: preset === 'solid'
|
|
68
|
-
? 'import { render } from \'solid-js/web\'\n'
|
|
69
|
-
: ''
|
|
70
|
-
%><% if (installTestingLibrary) { %>
|
|
71
|
-
|
|
72
|
-
import * as matchers from '@testing-library/jest-dom/matchers'
|
|
73
|
-
expect.extend(matchers)
|
|
74
|
-
<% } else if (preset === 'preact') { %>
|
|
75
|
-
import {h} from 'preact'
|
|
76
|
-
<% } %>
|
|
77
|
-
// ToDo: fix me
|
|
78
|
-
<%- importStatement %>
|
|
79
|
-
|
|
80
|
-
describe('<%- (preset || 'my') %> component tests', () => {<%
|
|
81
|
-
if (preset === 'solid') { %>
|
|
82
|
-
const ref = document.createElement('div')
|
|
83
|
-
|
|
84
|
-
before(() => {
|
|
85
|
-
document.body.appendChild(ref);
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
after(() => {
|
|
89
|
-
document.body.removeChild(ref);
|
|
90
|
-
})
|
|
91
|
-
<% } %>
|
|
92
|
-
it('should test my component', async () => {
|
|
93
|
-
<%- renderStatement %>
|
|
94
|
-
|
|
95
|
-
const elem = await $(component)
|
|
96
|
-
await elem.click()
|
|
97
|
-
<%- assertionStatement %>
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
24
|
<% } else {
|
|
101
25
|
|
|
102
26
|
/**
|
|
@@ -16,7 +16,9 @@ export const config: Options.Testrunner = {<%
|
|
|
16
16
|
if (answers.runner === 'browser') {
|
|
17
17
|
if (answers.preset) {
|
|
18
18
|
%>['browser', {
|
|
19
|
-
preset: '<%- answers.preset %>'
|
|
19
|
+
preset: '<%- answers.preset %>',
|
|
20
|
+
// start browser window when `DEBUG` environment variable is set
|
|
21
|
+
headless: !Boolean(process.env.DEBUG)
|
|
20
22
|
}]<%
|
|
21
23
|
} else {
|
|
22
24
|
%>'browser'<%
|
package/build/utils.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export declare function hasPackage(pkg: string): Promise<boolean>;
|
|
|
96
96
|
* generate test files based on CLI answers
|
|
97
97
|
*/
|
|
98
98
|
export declare function generateTestFiles(answers: ParsedAnswers): Promise<void>;
|
|
99
|
+
export declare function generateBrowserRunnerTestFiles(answers: ParsedAnswers): Promise<void>;
|
|
99
100
|
export declare function getAnswers(yes: boolean): Promise<Questionnair>;
|
|
100
101
|
export declare function getPathForFileGeneration(answers: Questionnair, projectRootDir: string): {
|
|
101
102
|
destSpecRootPath: string;
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAIA,OAA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,QAoDxF;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,aAAa,EAAE,aAAa,iBAyCjE;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,aAAa,EAAE,aAAa,iBA4C5D;AAED,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,aAAa,iBAgBlE;AAED,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,aAAa,oBAkBlE"}
|
package/build/utils.js
CHANGED
|
@@ -323,6 +323,46 @@ export async function hasPackage(pkg) {
|
|
|
323
323
|
* generate test files based on CLI answers
|
|
324
324
|
*/
|
|
325
325
|
export async function generateTestFiles(answers) {
|
|
326
|
+
if (answers.runner === 'local') {
|
|
327
|
+
return generateLocalRunnerTestFiles(answers);
|
|
328
|
+
}
|
|
329
|
+
return generateBrowserRunnerTestFiles(answers);
|
|
330
|
+
}
|
|
331
|
+
const TSX_BASED_FRAMEWORKS = ['react', 'preact', 'solid'];
|
|
332
|
+
export async function generateBrowserRunnerTestFiles(answers) {
|
|
333
|
+
const isUsingFramework = typeof answers.preset === 'string';
|
|
334
|
+
const preset = isUsingFramework
|
|
335
|
+
? answers.preset || 'lit'
|
|
336
|
+
: '';
|
|
337
|
+
const tplRootDir = path.join(TEMPLATE_ROOT_DIR, 'browser');
|
|
338
|
+
await fs.mkdir(answers.destSpecRootPath, { recursive: true });
|
|
339
|
+
/**
|
|
340
|
+
* render css file
|
|
341
|
+
*/
|
|
342
|
+
if (isUsingFramework) {
|
|
343
|
+
const renderedCss = await renderFile(path.join(tplRootDir, 'Component.css.ejs'), answers);
|
|
344
|
+
await fs.writeFile(path.join(answers.destSpecRootPath, 'Component.css'), renderedCss);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* render component file
|
|
348
|
+
*/
|
|
349
|
+
const testExt = `${(answers.isUsingTypeScript ? 'ts' : 'js')}${TSX_BASED_FRAMEWORKS.includes(preset) ? 'x' : ''}`;
|
|
350
|
+
const fileExt = ['svelte', 'vue'].includes(preset)
|
|
351
|
+
? preset
|
|
352
|
+
: testExt;
|
|
353
|
+
if (preset) {
|
|
354
|
+
const componentOutFileName = `Component.${fileExt}`;
|
|
355
|
+
const renderedComponent = await renderFile(path.join(tplRootDir, `Component.${preset}.ejs`), answers);
|
|
356
|
+
await fs.writeFile(path.join(answers.destSpecRootPath, componentOutFileName), renderedComponent);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* render test file
|
|
360
|
+
*/
|
|
361
|
+
const componentFileName = preset ? `Component.${preset}.test.ejs` : 'standalone.test.ejs';
|
|
362
|
+
const renderedTest = await renderFile(path.join(tplRootDir, componentFileName), answers);
|
|
363
|
+
await fs.writeFile(path.join(answers.destSpecRootPath, `Component.test.${testExt}`), renderedTest);
|
|
364
|
+
}
|
|
365
|
+
async function generateLocalRunnerTestFiles(answers) {
|
|
326
366
|
const testFiles = answers.framework === 'cucumber'
|
|
327
367
|
? [path.join(TEMPLATE_ROOT_DIR, 'cucumber')]
|
|
328
368
|
: (answers.framework === 'mocha'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/cli",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.3",
|
|
4
4
|
"description": "WebdriverIO testrunner command line interface",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-cli",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"typeScriptVersion": "3.8.3",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@types/node": "^18.0.0",
|
|
37
|
-
"@wdio/config": "8.6.
|
|
38
|
-
"@wdio/globals": "8.6.
|
|
37
|
+
"@wdio/config": "8.6.2",
|
|
38
|
+
"@wdio/globals": "8.6.3",
|
|
39
39
|
"@wdio/logger": "8.1.0",
|
|
40
40
|
"@wdio/protocols": "8.5.7",
|
|
41
41
|
"@wdio/types": "8.4.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"mkdirp": "^2.0.0",
|
|
55
55
|
"read-pkg-up": "9.1.0",
|
|
56
56
|
"recursive-readdir": "^2.2.2",
|
|
57
|
-
"webdriverio": "8.6.
|
|
57
|
+
"webdriverio": "8.6.3",
|
|
58
58
|
"yargs": "^17.5.1",
|
|
59
59
|
"yarn-install": "^1.0.0"
|
|
60
60
|
},
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "24bb631283562f45dd2bdcb622a0c0d93cf075c2"
|
|
75
75
|
}
|