Skip to content

Commit 98c6198

Browse files
committed
Merge branch '3.x' into feat-soft-assertion
2 parents baa888c + b960479 commit 98c6198

File tree

18 files changed

+545
-302
lines changed

18 files changed

+545
-302
lines changed

.github/workflows/appiumV2_Android.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ env:
99
CI: true
1010
# Force terminal colors. @see https://www.npmjs.com/package/colors
1111
FORCE_COLOR: 1
12+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
13+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
1214

1315
jobs:
1416
appium:
@@ -20,17 +22,23 @@ jobs:
2022
test-suite: ['other', 'quick']
2123

2224
steps:
23-
- uses: actions/checkout@v4
24-
- name: Use Node.js ${{ matrix.node-version }}
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: ${{ matrix.node-version }}
28-
- run: npm i --force
29-
env:
30-
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
31-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
32-
- run: "npm run test:appium-${{ matrix.test-suite }}"
33-
env: # Or as an environment variable
34-
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
35-
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
25+
- uses: actions/checkout@v4
3626

27+
- name: Use Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
32+
- run: npm i
33+
env:
34+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
35+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
36+
37+
- name: Upload APK to Sauce Labs
38+
run: |
39+
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \
40+
--location --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
41+
--form 'payload=@test/data/mobile/selendroid-test-app-0.17.0.apk' \
42+
--form 'name="selendroid-test-app-0.17.0.apk"'
43+
44+
- run: 'npm run test:appium-${{ matrix.test-suite }}'

.github/workflows/appiumV2_iOS.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ env:
99
CI: true
1010
# Force terminal colors. @see https://www.npmjs.com/package/colors
1111
FORCE_COLOR: 1
12+
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
13+
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
1214

1315
jobs:
1416
appium:
@@ -29,8 +31,12 @@ jobs:
2931
env:
3032
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
3133
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
32-
- run: "npm run test:ios:appium-${{ matrix.test-suite }}"
33-
env: # Or as an environment variable
34-
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
35-
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
3634

35+
- name: Upload APK to Sauce Labs
36+
run: |
37+
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" \
38+
--location --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' \
39+
--form 'payload=@test/data/mobile/TestApp-iphonesimulator.zip' \
40+
--form 'name="TestApp-iphonesimulator.zip"'
41+
42+
- run: 'npm run test:ios:appium-${{ matrix.test-suite }}'

.github/workflows/playwright.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,41 @@ env:
1515

1616
jobs:
1717
build:
18-
1918
runs-on: ubuntu-latest
2019

2120
strategy:
2221
matrix:
2322
node-version: [20.x]
2423

2524
steps:
26-
- uses: actions/checkout@v4
27-
- name: Use Node.js ${{ matrix.node-version }}
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: ${{ matrix.node-version }}
31-
- uses: shivammathur/setup-php@v2
32-
with:
33-
php-version: 7.4
34-
- name: npm install
35-
run: |
36-
npm i --force
37-
env:
38-
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
39-
- name: Install browsers and deps
40-
run: npx playwright install && npx playwright install-deps
41-
- name: start a server
42-
run: "php -S 127.0.0.1:8000 -t test/data/app &"
43-
- name: run chromium tests
44-
run: "./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"
45-
- name: run chromium with restart==browser tests
46-
run: "BROWSER_RESTART=browser ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"
47-
- name: run chromium with restart==session tests
48-
run: "BROWSER_RESTART=session ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"
49-
- name: run firefox tests
50-
run: "BROWSER=firefox node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"
51-
- name: run webkit tests
52-
run: "BROWSER=webkit node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug"
53-
- name: run chromium unit tests
54-
run: ./node_modules/.bin/mocha test/helper/Playwright_test.js --timeout 5000
25+
- uses: actions/checkout@v4
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
- uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: 7.4
33+
- name: npm install
34+
run: |
35+
npm i --force
36+
env:
37+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
38+
- name: Install browsers and deps
39+
run: npx playwright install && npx playwright install-deps
40+
- name: check
41+
run: './bin/codecept.js check -c test/acceptance/codecept.Playwright.js'
42+
- name: start a server
43+
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
44+
- name: run chromium tests
45+
run: './bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
46+
- name: run chromium with restart==browser tests
47+
run: 'BROWSER_RESTART=browser ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
48+
- name: run chromium with restart==session tests
49+
run: 'BROWSER_RESTART=session ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
50+
- name: run firefox tests
51+
run: 'BROWSER=firefox node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
52+
- name: run webkit tests
53+
run: 'BROWSER=webkit node ./bin/codecept.js run -c test/acceptance/codecept.Playwright.js --grep @Playwright --debug'
54+
- name: run chromium unit tests
55+
run: ./node_modules/.bin/mocha test/helper/Playwright_test.js --timeout 5000

.github/workflows/webdriver.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
3939
- name: start a server
4040
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
41+
- name: Check CodeceptJS can be started
42+
run: './bin/codecept.js check -c test/acceptance/codecept.WebDriver.js'
4143
- name: run unit tests
4244
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit
4345
- name: run tests

bin/codecept.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ program
5858
.description('Creates dummy config in current dir or [path]')
5959
.action(errorHandler(require('../lib/command/init')))
6060

61+
program
62+
.command('check')
63+
.option(commandFlags.config.flag, commandFlags.config.description)
64+
.description('Checks configuration and environment before running tests')
65+
.option('-t, --timeout [ms]', 'timeout for checks in ms, 20000 by default')
66+
.action(errorHandler(require('../lib/command/check')))
67+
6168
program
6269
.command('migrate [path]')
6370
.description('Migrate json config to js config in current dir or [path]')

docs/helpers/Appium.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,19 +550,10 @@ Hide the keyboard.
550550
```js
551551
// taps outside to hide keyboard per default
552552
I.hideDeviceKeyboard();
553-
I.hideDeviceKeyboard('tapOutside');
554-
555-
// or by pressing key
556-
I.hideDeviceKeyboard('pressKey', 'Done');
557553
```
558554

559555
Appium: support Android and iOS
560556

561-
#### Parameters
562-
563-
* `strategy` **(`"tapOutside"` | `"pressKey"`)?** Desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
564-
* `key` **[string][5]?** Optional key
565-
566557
### sendDeviceKeyEvent
567558

568559
Send a key event to the device.

lib/command/check.js

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
const { getConfig, getTestRoot } = require('./utils')
2+
const Codecept = require('../codecept')
3+
const output = require('../output')
4+
const standardActingHelpers = require('../plugin/standardActingHelpers')
5+
const store = require('../store')
6+
const container = require('../container')
7+
const figures = require('figures')
8+
const chalk = require('chalk')
9+
const { createTest } = require('../mocha/test')
10+
const { getMachineInfo } = require('./info')
11+
const definitions = require('./definitions')
12+
13+
module.exports = async function (options) {
14+
const configFile = options.config
15+
16+
setTimeout(() => {
17+
output.error("Something went wrong. Checks didn't pass and timed out. Please check your config and helpers.")
18+
process.exit(1)
19+
}, options.timeout || 50000)
20+
21+
const checks = {
22+
config: false,
23+
container: false,
24+
pageObjects: false,
25+
helpers: false,
26+
setup: false,
27+
tests: false,
28+
def: false,
29+
}
30+
31+
const testRoot = getTestRoot(configFile)
32+
let config = getConfig(configFile)
33+
34+
try {
35+
config = getConfig(configFile)
36+
checks['config'] = true
37+
} catch (err) {
38+
checks['config'] = err
39+
}
40+
41+
printCheck('config', checks['config'], config.name)
42+
43+
let codecept
44+
try {
45+
codecept = new Codecept(config, options)
46+
codecept.init(testRoot)
47+
await container.started()
48+
checks.container = true
49+
} catch (err) {
50+
checks.container = err
51+
}
52+
53+
printCheck('container', checks['container'])
54+
55+
if (codecept) {
56+
try {
57+
if (options.bootstrap) await codecept.bootstrap()
58+
checks.bootstrap = true
59+
} catch (err) {
60+
checks.bootstrap = err
61+
}
62+
printCheck('bootstrap', checks['bootstrap'], options.bootstrap ? 'Bootstrap was executed' : 'No bootstrap command')
63+
}
64+
65+
let numTests = 0
66+
if (codecept) {
67+
try {
68+
codecept.loadTests()
69+
const mocha = container.mocha()
70+
mocha.files = codecept.testFiles
71+
mocha.loadFiles()
72+
mocha.suite.suites.forEach(suite => {
73+
numTests += suite.tests.length
74+
})
75+
if (numTests > 0) {
76+
checks.tests = true
77+
} else {
78+
throw new Error('No tests found')
79+
}
80+
} catch (err) {
81+
checks.tests = err
82+
}
83+
}
84+
85+
printCheck('tests', checks['tests'], `Total: ${numTests} tests`)
86+
87+
store.dryRun = true
88+
89+
const helpers = container.helpers()
90+
91+
try {
92+
if (!Object.keys(helpers).length) throw new Error('No helpers found')
93+
// load helpers
94+
for (const helper of Object.values(helpers)) {
95+
if (helper._init) helper._init()
96+
}
97+
checks.helpers = true
98+
} catch (err) {
99+
checks.helpers = err
100+
}
101+
102+
printCheck('helpers', checks['helpers'], `${Object.keys(helpers).join(', ')}`)
103+
104+
const pageObjects = container.support()
105+
106+
try {
107+
if (Object.keys(pageObjects).length) {
108+
for (const pageObject of Object.values(pageObjects)) {
109+
pageObject.name
110+
}
111+
}
112+
checks.pageObjects = true
113+
} catch (err) {
114+
checks.pageObjects = err
115+
}
116+
printCheck('page objects', checks['pageObjects'], `Total: ${Object.keys(pageObjects).length} support objects`)
117+
118+
if (Object.keys(helpers).length) {
119+
const suite = container.mocha().suite
120+
const test = createTest('test', () => {})
121+
try {
122+
for (const helper of Object.values(helpers)) {
123+
if (helper._beforeSuite) await helper._beforeSuite(suite)
124+
if (helper._before) await helper._before(test)
125+
if (helper._passed) await helper._passed(test)
126+
if (helper._after) await helper._after(test)
127+
if (helper._finishTest) await helper._finishTest(suite)
128+
if (helper._afterSuite) await helper._afterSuite(suite)
129+
}
130+
checks.setup = true
131+
} catch (err) {
132+
checks.setup = err
133+
}
134+
}
135+
136+
printCheck('Helpers Before/After', checks['setup'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Initializing and closing browser' : '')
137+
138+
try {
139+
definitions(configFile, { dryRun: true })
140+
checks.def = true
141+
} catch (err) {
142+
checks.def = err
143+
}
144+
145+
printCheck('TypeScript Definitions', checks['def'])
146+
147+
output.print('')
148+
149+
if (!Object.values(checks).every(check => check === true)) {
150+
output.error("Something went wrong. Checks didn't pass.")
151+
output.print()
152+
await getMachineInfo()
153+
process.exit(1)
154+
}
155+
156+
output.print(output.styles.success('All checks passed'.toUpperCase()), 'Ready to run your tests 🚀')
157+
process.exit(0)
158+
}
159+
160+
function printCheck(name, value, comment = '') {
161+
let status = ''
162+
if (value == true) {
163+
status += chalk.bold.green(figures.tick)
164+
} else {
165+
status += chalk.bold.red(figures.cross)
166+
}
167+
168+
if (value instanceof Error) {
169+
comment = `${comment} ${chalk.red.italic(value.message)}`.trim()
170+
}
171+
172+
output.print(status, name.toUpperCase(), chalk.dim(comment))
173+
}

lib/command/definitions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ module.exports = function (genPath, options) {
185185
definitionsFileContent += `\n${translationAliases.join('\n')}`
186186
}
187187

188+
if (options.dryRun) return
189+
188190
fs.writeFileSync(path.join(targetFolderPath, 'steps.d.ts'), definitionsFileContent)
189191
output.print('TypeScript Definitions provide autocompletion in Visual Studio Code and other IDEs')
190192
output.print('Definitions were generated in steps.d.ts')

0 commit comments

Comments
 (0)