MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / tests

Function tests

test/helper/webapi.js:31–2608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31export function tests() {
32 const isHelper = helperName => I.constructor.name === helperName
33
34 beforeEach(() => {
35 I = data.I
36 siteUrl = data.siteUrl
37 if (fileExists(dataFile)) fs.unlinkSync(dataFile)
38 })
39
40 describe('#saveElementScreenshot', () => {
41 beforeEach(() => {
42 global.output_dir = path.join(global.codecept_dir, 'output')
43 })
44
45 it('should create a screenshot file in output dir of element', async () => {
46 await I.amOnPage('/form/field')
47 await I.seeElement("input[name='name']")
48 const sec = new Date().getUTCMilliseconds()
49 await I.saveElementScreenshot("input[name='name']", `element_screenshot_${sec}.png`)
50 assert.ok(fileExists(path.join(global.output_dir, `element_screenshot_${sec}.png`)), null, 'file does not exists')
51 })
52 })
53
54 describe('current url : #seeInCurrentUrl, #seeCurrentUrlEquals, #grabCurrentUrl, ...', () => {
55 it('should check for url fragment', async () => {
56 await I.amOnPage('/form/checkbox')
57 await I.seeInCurrentUrl('/form')
58 await I.dontSeeInCurrentUrl('/user')
59 })
60
61 it('should check for equality', async () => {
62 await I.amOnPage('/info')
63 await I.seeCurrentUrlEquals('/info')
64 await I.dontSeeCurrentUrlEquals('form')
65 })
66
67 it('should check for equality in absolute urls', async () => {
68 await I.amOnPage('/info')
69 await I.seeCurrentUrlEquals(`${siteUrl}/info`)
70 await I.dontSeeCurrentUrlEquals(`${siteUrl}/form`)
71 })
72
73 it('should grab browser url', async () => {
74 await I.amOnPage('/info')
75 const url = await I.grabCurrentUrl()
76 assert.equal(url, `${siteUrl}/info`)
77 })
78
79 it('should check for equality with query strings', async () => {
80 await I.amOnPage('/info?user=test')
81 // Query strings matter for exact equality
82 await I.seeCurrentUrlEquals('/info?user=test')
83 await I.dontSeeCurrentUrlEquals('/info')
84 // But substring check works
85 await I.seeInCurrentUrl('/info')
86 await I.seeInCurrentUrl('user=test')
87 })
88

Callers

nothing calls this directly

Calls 15

fileExistsFunction · 0.90
doneFunction · 0.85
openFunction · 0.85
submitAndGrabFunction · 0.85
openSiblingPageFunction · 0.85
outerTitleValueFunction · 0.85
failMethod · 0.80
includesMethod · 0.80
fetchDetailsMethod · 0.80
isHelperFunction · 0.70
amOnPageMethod · 0.45
seeElementMethod · 0.45

Tested by

no test coverage detected