Skip to content

Commit 0002eac

Browse files
DavertMikclaude
andcommitted
Merge branch '4.x' into feat/locator-json-as-string
Resolved conflict in test/unit/plugin/htmlReporter_test.js by keeping ESM import. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2 parents 4f86c34 + 962ba93 commit 0002eac

File tree

9 files changed

+204
-190
lines changed

9 files changed

+204
-190
lines changed

docs/helpers/WebDriver.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,21 @@ const webElement = await I.grabWebElement('#button');
14691469
14701470
Returns **[Promise][23]<any>** WebElement of being used Web helper
14711471
1472+
### grabWebElement
1473+
1474+
Grab WebElement for given locator
1475+
Resumes test execution, so **should be used inside an async function with `await`** operator.
1476+
1477+
```js
1478+
const webElement = await I.grabWebElement('#button');
1479+
```
1480+
1481+
#### Parameters
1482+
1483+
* `locator` **([string][18] | [object][17])** element located by CSS|XPath|strict locator.
1484+
1485+
Returns **[Promise][26]<any>** WebElement of being used Web helper
1486+
14721487
### grabWebElements
14731488
14741489
Grab WebElements for given locator
File renamed without changes.

test/data/sandbox/custom-worker/custom_test.worker.js renamed to test/data/sandbox/custom-worker/2_custom_test.worker.js

File renamed without changes.
File renamed without changes.

test/helper/Playwright_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,11 @@ describe('Playwright', function () {
11011101

11021102
it('should convert to axios response with onResponse hook', async () => {
11031103
let response
1104+
<<<<<<< HEAD
11041105
I.options.onResponse = resp => (response = resp)
1106+
=======
1107+
I.config.onResponse = resp => (response = resp)
1108+
>>>>>>> 875a660b5219dd2475883ed35db6adb58852216f
11051109
await I.makeApiRequest('get', 'http://localhost:3001/api/users?page=2')
11061110
expect(response).to.be.ok
11071111
expect(response.status).to.equal(200)
@@ -2087,6 +2091,7 @@ describe('Playwright - storageState file path', function () {
20872091
} catch (_) {}
20882092
})
20892093
})
2094+
<<<<<<< HEAD
20902095

20912096
// Global after hook to ensure process exits after all tests complete
20922097
// This prevents the process from hanging due to Playwright event loops
@@ -2097,3 +2102,5 @@ after(function () {
20972102
}, 1000).unref()
20982103
}
20992104
})
2105+
=======
2106+
>>>>>>> 875a660b5219dd2475883ed35db6adb58852216f

test/helper/TestCafe_test.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
const path = require('path')
2+
const assert = require('assert')
3+
4+
const TestHelper = require('../support/TestHelper')
5+
const TestCafe = require('../../lib/helper/TestCafe')
6+
const webApiTests = require('./webapi')
7+
global.codeceptjs = require('../../lib')
8+
9+
let I
10+
const siteUrl = TestHelper.siteUrl()
11+
12+
describe('TestCafe', function () {
13+
this.timeout(60000) // Reduced timeout from 120s to 60s for faster feedback
14+
this.retries(1)
15+
16+
before(() => {
17+
global.codecept_dir = path.join(__dirname, '/../data')
18+
global.output_dir = path.join(__dirname, '/../data/output')
19+
global.codeceptjs = require('../../lib/index')
20+
21+
I = new TestCafe({
22+
url: siteUrl,
23+
windowSize: '1000x700',
24+
show: false,
25+
browser: 'chrome:headless --no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage --disable-gpu',
26+
restart: false,
27+
waitForTimeout: 50000,
28+
})
29+
I._init()
30+
return I._beforeSuite()
31+
})
32+
33+
after(() => {
34+
return I._finishTest()
35+
})
36+
37+
beforeEach(() => {
38+
webApiTests.init({
39+
I,
40+
siteUrl,
41+
})
42+
return I._before().then(() => {
43+
page = I.page
44+
browser = I.browser
45+
})
46+
})
47+
48+
afterEach(() => {
49+
return I._after()
50+
})
51+
52+
describe('open page : #amOnPage', () => {
53+
it('should open main page of configured site', async () => {
54+
await I.amOnPage('/')
55+
const url = await I.grabCurrentUrl()
56+
await url.should.eql(`${siteUrl}/`)
57+
})
58+
it('should open any page of configured site', async () => {
59+
await I.amOnPage('/info')
60+
const url = await I.grabCurrentUrl()
61+
return url.should.eql(`${siteUrl}/info`)
62+
})
63+
64+
it('should open absolute url', async () => {
65+
await I.amOnPage(siteUrl)
66+
const url = await I.grabCurrentUrl()
67+
return url.should.eql(`${siteUrl}/`)
68+
})
69+
})
70+
71+
describe('#waitForFunction', () => {
72+
it('should wait for function returns true', () => {
73+
return I.amOnPage('/form/wait_js').then(() => I.waitForFunction(() => window.__waitJs, 3))
74+
})
75+
76+
it('should pass arguments and wait for function returns true', () => {
77+
return I.amOnPage('/form/wait_js').then(() => I.waitForFunction(varName => window[varName], ['__waitJs'], 3))
78+
})
79+
})
80+
81+
webApiTests.tests()
82+
83+
describe('#useTestCafeTo', () => {
84+
it('should return title', async () => {
85+
await I.amOnPage('/')
86+
const title = await I.useTestCafeTo('test', async ({ t }) => {
87+
return t.eval(() => document.title, { boundTestRun: null })
88+
})
89+
assert.equal('TestEd Beta 2.0', title)
90+
})
91+
})
92+
})
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
const expect = require('chai').expect
2+
const Codecept = require('../../lib/codecept')
3+
const path = require('path')
4+
const fs = require('fs')
5+
6+
describe('Test Files Alphabetical Order', () => {
7+
let codecept
8+
const tempDir = path.join(__dirname, '../data/sandbox/configs/alphabetical_order')
9+
const config = {
10+
tests: `${tempDir}/*_test.js`,
11+
gherkin: { features: null },
12+
output: './output',
13+
hooks: [],
14+
}
15+
16+
before(() => {
17+
if (!fs.existsSync(tempDir)) {
18+
fs.mkdirSync(tempDir, { recursive: true })
19+
}
20+
21+
fs.writeFileSync(
22+
path.join(tempDir, 'zzz_test.js'),
23+
`
24+
Feature('Test');
25+
Scenario('zzz test', () => {});
26+
`,
27+
)
28+
fs.writeFileSync(
29+
path.join(tempDir, 'aaa_test.js'),
30+
`
31+
Feature('Test');
32+
Scenario('aaa test', () => {});
33+
`,
34+
)
35+
fs.writeFileSync(
36+
path.join(tempDir, 'mmm_test.js'),
37+
`
38+
Feature('Test');
39+
Scenario('mmm test', () => {});
40+
`,
41+
)
42+
})
43+
44+
after(() => {
45+
const files = ['zzz_test.js', 'aaa_test.js', 'mmm_test.js']
46+
files.forEach(file => {
47+
const filePath = path.join(tempDir, file)
48+
if (fs.existsSync(filePath)) {
49+
fs.unlinkSync(filePath)
50+
}
51+
})
52+
})
53+
54+
beforeEach(() => {
55+
codecept = new Codecept(config, {})
56+
codecept.init(path.join(__dirname, '../data/sandbox'))
57+
})
58+
59+
it('should sort test files alphabetically after loading', () => {
60+
codecept.loadTests()
61+
62+
if (codecept.testFiles.length === 0) {
63+
console.log('No test files found, skipping test')
64+
return
65+
}
66+
67+
const filenames = codecept.testFiles.map(filePath => path.basename(filePath))
68+
69+
const sortedFilenames = [...filenames].sort()
70+
71+
expect(filenames).to.deep.equal(sortedFilenames)
72+
73+
const aaaIndex = filenames.findIndex(f => f.includes('aaa_test.js'))
74+
const mmmIndex = filenames.findIndex(f => f.includes('mmm_test.js'))
75+
const zzzIndex = filenames.findIndex(f => f.includes('zzz_test.js'))
76+
77+
expect(aaaIndex).to.be.greaterThan(-1)
78+
expect(mmmIndex).to.be.greaterThan(-1)
79+
expect(zzzIndex).to.be.greaterThan(-1)
80+
81+
expect(aaaIndex).to.be.lessThan(mmmIndex, 'aaa_test.js should come before mmm_test.js')
82+
expect(mmmIndex).to.be.lessThan(zzzIndex, 'mmm_test.js should come before zzz_test.js')
83+
})
84+
})

0 commit comments

Comments
 (0)