CodeceptJS Versions Save

Supercharged End 2 End Testing Framework for NodeJS

3.6.1

3 weeks ago

Fixed regression in interactive pause.

3.6.0

4 weeks ago

3.6.0

🛩ī¸ Features

  • Introduced healers to improve stability of failed tests. Write functions that can perform actions to fix a failing test:
heal.addRecipe('reloadPageIfModalIsNotVisisble', {
  steps: [
    'click',
  ],
  fn: async ({ error, step }) => {
    // this function will be executed only if test failed with
    // "model is not visible" message
    if (error.message.include('modal is not visible')) return;

    // we return a function that will refresh a page
    // and tries to perform last step again
    return async ({ I }) => {
      I.reloadPage();
      I.wait(1);
      await step.run();
    };
    // if a function succeeds, test continues without an error
  },
});
  • Breaking Change AI features refactored. Read updated AI guide:

    • removed dependency on openai
    • added support for Azure OpenAI, Claude, Mistal, or any AI via custom request function
    • --ai option added to explicitly enable AI features
    • heal plugin decoupled from AI to run custom heal recipes
    • improved healing for async/await scenarios
    • token limits added
    • token calculation introduced
    • OpenAI helper renamed to AI
  • feat(puppeteer): network traffic manipulation. See #4263 by @KobeNguyenT

    • startRecordingTraffic
    • grabRecordedNetworkTraffics
    • flushNetworkTraffics
    • stopRecordingTraffic
    • seeTraffic
    • dontSeeTraffic
  • feat(Puppeteer): recording WS messages. See #4264 by @KobeNguyenT

Recording WS messages:

      I.startRecordingWebSocketMessages();
      I.amOnPage('https://websocketstest.com/');
      I.waitForText('Work for You!');
      const wsMessages = I.grabWebSocketMessages();
      expect(wsMessages.length).to.greaterThan(0);

flushing WS messages:

      I.startRecordingWebSocketMessages();
      I.amOnPage('https://websocketstest.com/');
      I.waitForText('Work for You!');
      I.flushWebSocketMessages();
      const wsMessages = I.grabWebSocketMessages();
      expect(wsMessages.length).to.equal(0);

Examples:

// recording traffics and verify the traffic
  I.startRecordingTraffic();
  I.amOnPage('https://codecept.io/');
  I.seeTraffic({ name: 'traffics', url: 'https://codecept.io/img/companies/BC_LogoScreen_C.jpg' });
// check the traffic with advanced params
  I.amOnPage('https://openai.com/blog/chatgpt');
  I.startRecordingTraffic();
  I.seeTraffic({
    name: 'sentry event',
    url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
    parameters: {
      width: '1919',
      height: '1138',
    },
  });
  • Introduce the playwright locator: _react, _vue, data-testid attribute. See #4255 by @KobeNguyenT
Scenario('using playwright locator @Playwright', () => {
  I.amOnPage('https://codecept.io/test-react-calculator/');
  I.click('7');
  I.click({ pw: '_react=t[name = "="]' });
  I.seeElement({ pw: '_react=t[value = "7"]' });
  I.click({ pw: '_react=t[name = "+"]' });
  I.click({ pw: '_react=t[name = "3"]' });
  I.click({ pw: '_react=t[name = "="]' });
  I.seeElement({ pw: '_react=t[value = "10"]' });
});
Scenario('using playwright data-testid attribute @Playwright', () => {
    I.amOnPage('/');
    const webElements = await I.grabWebElements({ pw: '[data-testid="welcome"]' });
    assert.equal(webElements[0]._selector, '[data-testid="welcome"] >> nth=0');
    assert.equal(webElements.length, 1);
});
  • feat(puppeteer): mockRoute support. See #4262 by @KobeNguyenT

Network requests & responses can be mocked and modified. Use mockRoute which strictly follows Puppeteer's setRequestInterception API.

I.mockRoute('https://reqres.in/api/comments/1', request => {
  request.respond({
    status: 200,
    headers: { 'Access-Control-Allow-Origin': '*' },
    contentType: 'application/json',
    body: '{"name": "this was mocked" }',
  });
})
I.mockRoute('**/*.{png,jpg,jpeg}', route => route.abort());
// To disable mocking for a route call `stopMockingRoute`
// for previously mocked URL
I.stopMockingRoute('**/*.{png,jpg,jpeg}');

To master request intercepting use HTTPRequest object passed into mock request handler.

🐛 Bug Fixes

  • Fixed double help message #4278 by @masiuchi
  • waitNumberOfVisibleElements always failed when passing num as 0. See #4274 by @KobeNguyenT

New Contributors

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.15...3.6.0

3.5.15

1 month ago

3.5.15

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

  • feat: improve code coverage plugin (#4252) - by KobeNguyenT We revamp the coverage plugin to make it easier to use

Once all the tests are completed, codecept will create and store coverage in output/coverage folder, as shown below.

Open index.html in your browser to view the full interactive coverage report.

🐛 Bug Fixes

dry-run command now supports test level grep.

Tests from /Users/t/Desktop/projects/codeceptjs-rest-demo:@jaja

GET tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/GET_test.ts -- 4 tests
  ☐ Verify getting a single user **[jaja](https://github.com/jaja)**
  ☐ Verify getting list of users **[jaja](https://github.com/jaja)**
PUT tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/PUT_test.ts -- 4 tests
  ☐ Verify creating new user **[Jaja](https://github.com/Jaja)**


  Total: 2 suites | 3 tests  

--- DRY MODE: No tests were executed ---
➜  codeceptjs-rest-demo git:(master) ✗ npx codeceptjs dry-run             
Tests from /Users/t/Desktop/projects/codeceptjs-rest-demo:

DELETE tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/DELETE_test.ts -- 4 tests
  ☐ Verify deleting a user
GET tests -- /Users/t/Desktop/projects/codeceptjs-rest-demo/src/GET_test.ts -- 4 tests
  ☐ Verify a successful call
  ☐ Verify a not found call
  ☐ Verify getting a single user **[jaja](https://github.com/jaja)**
  ☐ Verify getting list of users **[jaja](https://github.com/jaja)**
POST tests -- /Users/tDesktop/projects/codeceptjs-rest-demo/src/POST_test.ts -- 4 tests
  ☐ Verify creating new user
  ☐ Verify uploading a file
PUT tests -- /Users/tDesktop/projects/codeceptjs-rest-demo/src/PUT_test.ts -- 4 tests
  ☐ Verify creating new user **[Jaja](https://github.com/Jaja)**


  Total: 4 suites | 8 tests  

--- DRY MODE: No tests were executed ---
  • Several internal fixes and improvements for github workflows

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.14...3.5.15

3.5.14

2 months ago

What's Changed

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.13...3.5.14

3.5.13

2 months ago

3.5.13

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

  • feat: mock server helper (#4155) - by @KobeNguyenT Screenshot 2024-01-25 at 13 47 59
  • feat(webdriver): network traffics manipulation (#4166) - by @KobeNguyenT [Webdriver] Added commands to check network traffics - supported only with devtoolsProtocol
    • startRecordingTraffic
    • grabRecordedNetworkTraffics
    • flushNetworkTraffics
    • stopRecordingTraffic
    • seeTraffic
    • dontSeeTraffic

Examples:

// recording traffics and verify the traffic
  I.startRecordingTraffic();
  I.amOnPage('https://codecept.io/');
  I.seeTraffic({ name: 'traffics', url: 'https://codecept.io/img/companies/BC_LogoScreen_C.jpg' });
// check the traffic with advanced params
  I.amOnPage('https://openai.com/blog/chatgpt');
  I.startRecordingTraffic();
  I.seeTraffic({
    name: 'sentry event',
    url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
    parameters: {
      width: '1919',
      height: '1138',
    },
  });
  • feat(webapi): add waitForCookie (#4169) - by @KobeNguyenT Waits for the specified cookie in the cookies.
I.waitForCookie("token");

🐛 Bug Fixes

  • fix(appium): update performSwipe with w3c protocol v2 (#4181) - by @MykaLev
  • fix(webapi): selectOption method (#4157) - by @dyaroman
  • fix: waitForText doesnt throw error when text doesnt exist (#4195) - by @KobeNguyenT
  • fix: use this.options instead of this.config (#4186) - by @KobeNguyenT
  • fix: config path without selenium (#4184) - by @KobeNguyenT
  • fix: bring to front condition in _setPage (#4173) - by @KobeNguyenT
  • fix: complicated locator (#4170) - by @KobeNguyenT Adding of ':nth-child' into the array

const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang']; fixes the issue. Then an old conversion way over css-to-xpath is used.

📖 Documentation

  • fix(docs): missing docs for codecept UI (#4175) - by @KobeNguyenT
  • fix(docs): Appium documentation sidebar menu links (#4188) - by @mirao

🛩ī¸ Several bugfixes and improvements for Codecept-UI

  • Several internal improvements
  • fix: title is not showing when visiting a test
  • fix: handle erros nicely

New Contributors

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.12...3.5.13

3.5.12

3 months ago

3.5.12

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

  • feat: upgrade wdio (#4123) - by @KobeNguyenT

    🛩ī¸ With the release of WebdriverIO version v8.14.0, and onwards, all driver management hassles are now a thing of the past 🙌. Read more here. One of the significant advantages of this update is that you can now get rid of any driver services you previously had to manage, such as wdio-chromedriver-service, wdio-geckodriver-service, wdio-edgedriver-service, wdio-safaridriver-service, and even @wdio/selenium-standalone-service.

For those who require custom driver options, fear not; WebDriver Helper allows you to pass in driver options through custom WebDriver configuration. If you have a custom grid, use a cloud service, or prefer to run your own driver, there's no need to worry since WebDriver Helper will only start a driver when there are no other connection information settings like hostname or port specified.

Example:

{
   helpers: {
     WebDriver : {
       smartWait: 5000,
       browser: "chrome",
       restart: false,
       windowSize: "maximize",
       timeouts: {
         "script": 60000,
         "page load": 10000
       }
     }
   }
}

Testing Chrome locally is now more convenient than ever. You can define a browser channel, and WebDriver Helper will take care of downloading the specified browser version for you. For example:

{
   helpers: {
     WebDriver : {
       smartWait: 5000,
       browser: "chrome",
       browserVersion: '116.0.5793.0', // or 'stable', 'beta', 'dev' or 'canary'
       restart: false,
       windowSize: "maximize",
       timeouts: {
         "script": 60000,
         "page load": 10000
       }
     }
   }
}
  • feat: wdio with devtools protocol (#4105) - by @KobeNguyenT

Running with devtools protocol

{
   helpers: {
     WebDriver : {
       url: "http://localhost",
       browser: "chrome",
       devtoolsProtocol: true,
       desiredCapabilities: {
         chromeOptions: {
           args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
         }
       }
     }
   }
}
  • feat: add a locator builder method withTextEquals() (#4100) - by @mirao

Find an element with exact text

locate('button').withTextEquals('Add');
  • feat: waitForNumberOfTabs (#4124) - by @KobeNguyenT

Waits for number of tabs.

I.waitForNumberOfTabs(2);
  • feat: I.say would be added to Test.steps array (#4145) - by @KobeNguyenT

Currently I.say is not added into the Test.steps array. This PR aims to add this to steps array so that we could use it to print steps in ReportPortal for instance.

Screenshot 2024-01-19 at 15 41 34

🐛 Bug Fixes

  • fix: reduce the package size to 2MB (#4138) - by @KobeNguyenT
  • fix(webapi): see attributes on elements (#4147) - by @KobeNguyenT
  • fix: some assertion methods (#4144) - by @KobeNguyenT

Improve the error message for seeElement, dontSeeElement, seeElementInDOM, dontSeeElementInDOM

The current error message doesn't really help when debugging issue also causes some problem described in #4140

Actual

      expected visible elements '[ELEMENT]' to be empty
      + expected - actual

      -[
      -  "ELEMENT"
      -]
      +[]

Updated

     Error: Element "h1" is still visible
      at seeElementError (lib/helper/errors/ElementAssertion.js:9:9)
      at Playwright.dontSeeElement (lib/helper/Playwright.js:1472:7)
  • fix: css to xpath backward compatibility (#4141) - by @KobeNguyenT
  • fix: grabRecordedNetworkTraffics throws error when being called twice (#4143) - by @KobeNguyenT
  • fix: missing steps of test when running with workers (#4127) - by @KobeNguyenT
Scenario('Verify getting list of users', async () => {
let res = await I.getUserPerPage(2);
res.data = []; // this line causes the issue
await I.expectEqual(res.data.data[0].id, 7);
});

at this time, res.data.data[0].id would throw undefined error and somehow the test is missing all its steps.

  • fix: process.env.profile when --profile isn't set in run-multiple mode (#4131) - by @mirao

process.env.profile is the string "undefined" instead of type undefined when no --profile is specified in the mode "run-multiple"

  • fix: session doesn't respect the context options (#4111) - by @KobeNguyenT
Helpers: Playwright
Plugins: screenshotOnFail, tryTo, retryFailedStep, retryTo, eachElement

Repro --
[1]  Starting recording promises
Timeouts:
â€ē [Session] Starting singleton browser session
Reproduce issue
I am on page "https://example.com"
â€ē [Browser:Error] Failed to load resource: the server responded with a status of 404 ()
â€ē [New Context] {}
user1: I am on page "https://example.com"
user1: I execute script () => {
return { width: window.screen.width, height: window.screen.height };
}
sessionScreen is {"width":375,"height":667}
✔ OK in 1890ms


OK  | 1 passed   // 4s
  • fix(plugin): retryTo issue (#4117) - by @KobeNguyenT Screenshot 2024-01-08 at 17 36 54

  • fix(types): CustomLocator typing broken for custom strict locators (#4120) - by @KobeNguyenT

  • fix: wrong output for skipped tests - by @KobeNguyenT

  • fix: no retry failed step after tryto block (#4103) - by @KobeNguyenT

  • fix: deprecate some JSON Wire Protocol commands (#4104) - by @KobeNguyenT

deprecate some JSON Wire Protocol commands: grabGeoLocation, setGeoLocation

  • fix: cannot locate complicated locator (#4101) - by @KobeNguyenT

Locator issue due to the lib changes

The locator locate(".ps-menu-button").withText("Authoring").inside(".ps-submenu-root:nth-child(3)") is translated to
3.5.8: //*[contains(concat(' ', normalize-space(./@class), ' '), ' ps-menu-button ')][contains(., 'Authoring')][ancestor::*[(contains(concat(' ', normalize-space(./@class), ' '), ' ps-submenu-root ') and count(preceding-sibling::*) = 2)]] and works well
3.5.11: //*[contains(@class, "ps-menu-button")][contains(., 'Authoring')][ancestor::*[3][contains(@class, "ps-submenu-root")]] and doesn't work (no clickable element found). Even if you test it in browser inspector, it doesn't work.

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.11...3.5.12

3.5.11

4 months ago

3.5.11

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

🐛 Bug Fixes

  • fix: step object is broken when step arg is a function (#4092) - by @KobeNguyenT
  • fix: step object is broken when step arg contains joi object (#4084) - by @KobeNguyenT
  • fix(expect helper): custom error message as optional param (#4082) - by @KobeNguyenT
  • fix(puppeteer): hide deprecation info (#4075) - by @KobeNguyenT
  • fix: seeattributesonelements throws error when attribute doesn't exist (#4073) - by @KobeNguyenT
  • fix: typo in agrs (#4077) - by @KobeNguyenT
  • fix: retryFailedStep is disabled for non tryTo steps (#4069) - by @KobeNguyenT
  • fix(typings): scrollintoview complains scrollintoviewoptions (#4067) - by @KobeNguyenT

📖 Documentation

  • fix(docs): some doc blocks are broken (#4076) - by @KobeNguyenT
  • fix(docs): expect docs (#4058) - by @KobeNguyenT

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.10...3.5.11

3.5.10

5 months ago

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

  • feat: expose WebElement (#4043) - by @KobeNguyenT
Now we expose the WebElements that are returned by the WebHelper and you could make the subsequence actions on them.

// Playwright helper would return the Locator

I.amOnPage('/form/focus_blur_elements');
const webElements = await I.grabWebElements('#button');
webElements[0].click();
  • feat(playwright): support HAR replaying (#3990) - by @KobeNguyenT
Replaying from HAR

 // Replay API requests from HAR.
 // Either use a matching response from the HAR,
 // or abort the request if nothing matches.
   I.replayFromHar('./output/har/something.har', { url: "*/**/api/v1/fruits" });
   I.amOnPage('https://demo.playwright.dev/api-mocking');
   I.see('CodeceptJS');
[Parameters]
harFilePath [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Path to recorded HAR file
opts [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)? [Options for replaying from HAR](https://playwright.dev/docs/api/class-page#page-route-from-har)
  • feat(playwright): support HAR recording (#3986) - by @KobeNguyenT
A HAR file is an HTTP Archive file that contains a record of all the network requests that are made when a page is loaded. 
It contains information about the request and response headers, cookies, content, timings, and more. 
You can use HAR files to mock network requests in your tests. HAR will be saved to output/har. 
More info could be found here https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har.

...
recordHar: {
    mode: 'minimal', // possible values: 'minimal'|'full'.
    content: 'embed' // possible values:  "omit"|"embed"|"attach".
}
...
  • improvement(playwright): support partial string for option (#4016) - by @KobeNguyenT
await I.amOnPage('/form/select');
await I.selectOption('Select your age', '21-');

🐛 Bug Fixes

  • fix(playwright): proceedSee could not find the element (#4006) - by @hatufacci
  • fix(appium): remove the vendor prefix of 'bstack:options' (#4053) - by @mojtabaalavi
  • fix(workers): event improvements (#3953) - by @KobeNguyenT
Emit the new event: event.workers.result.

CodeceptJS also exposes the env var `process.env.RUNS_WITH_WORKERS` when running tests with run-workers command so that you could handle the events better in your plugins/helpers.

const { event } = require('codeceptjs');

module.exports = function() {
    // this event would trigger the  `_publishResultsToTestrail` when running `run-workers` command
  event.dispatcher.on(event.workers.result, async () => {
    await _publishResultsToTestrail();
  });
  
  // this event would not trigger the  `_publishResultsToTestrail` multiple times when running `run-workers` command
  event.dispatcher.on(event.all.result, async () => {
      // when running `run` command, this env var is undefined
    if (!process.env.RUNS_WITH_WORKERS) await _publishResultsToTestrail();
  });
}
  • fix: ai html updates (#3962) - by @DavertMik
replaced minify library with a modern and more secure fork. Fixes [email protected] Regular Expression Denial of Service vulnerability #3829
AI class is implemented as singleton
refactored heal.js plugin to work on edge cases
add configuration params on number of fixes performed by ay heal
improved recorder class to add more verbose log
improved recorder class to ignore some of errors
  • fix(appium): closeApp supports both Android/iOS (#4046) - by @KobeNguyenT
  • fix: some security vulnerability of some packages (#4045) - by @KobeNguyenT
  • fix: seeAttributesOnElements check condition (#4029) - by @KobeNguyenT
  • fix: waitForText locator issue (#4039) - by @KobeNguyenT
Fixed this error:

locator.isVisible: Unexpected token "s" while parsing selector ":has-text('Were you able to resolve the resident's issue?') >> nth=0"
      at Playwright.waitForText (node_modules\codeceptjs\lib\helper\Playwright.js:2584:79)
  • fix: move to sha256 (#4038) - by @KobeNguyenT
  • fix: respect retries from retryfailedstep plugin in helpers (#4028) - by @KobeNguyenT
Currently inside the _before() of helpers for example Playwright, the retries is set there, however, when retryFailedStep plugin is enabled, the retries of recorder is still using the value from _before() not the value from retryFailedStep plugin.

Fix:

- introduce the process.env.FAILED_STEP_RETIRES which could be access everywhere as the helper won't know anything about the plugin.
- set default retries of Playwright to 3 to be on the same page with Puppeteer.
  • fix: examples in test title (#4030) - by @KobeNguyenT
When test title doesn't have the data in examples:

Feature: Faker examples

  Scenario Outline: Below are the users
    Examples:
      | user   | role |
      | John  | admin |
      | Tim   | client  |

Faker examples --
    [1]  Starting recording promises
    Timeouts: 
  Below are the users {"user":"John","role":"admin"}
  ✔ OK in 4ms

  Below are the users {"user":"Tim","role":"client"}
  ✔ OK in 1ms

When test title includes the data in examples:


Feature: Faker examples

  Scenario Outline: Below are the users - <user> - <role>
    Examples:
      | user   | role |
      | John  | admin |
      | Tim   | client  |


Faker examples --
    [1]  Starting recording promises
    Timeouts: 
  Below are the users - John - admin 
  ✔ OK in 4ms

  Below are the users - Tim - client 
  ✔ OK in 1ms
  • fix: disable retryFailedStep when using with tryTo (#4022) - by @KobeNguyenT
  • fix: locator builder returns error when class name contains hyphen (#4024) - by @KobeNguyenT
  • fix: seeCssPropertiesOnElements failed when font-weight is a number (#4026) - by @KobeNguyenT
  • fix(appium): missing await on some steps of runOnIOS and runOnAndroid (#4018) - by @KobeNguyenT
  • fix(cli): no error of failed tests when using retry with scenario only (#4020) - by @KobeNguyenT
  • fix: set getPageTimeout to 30s (#4031) - by @KobeNguyenT
  • fix(appium): expose switchToContext (#4015) - by @KobeNguyenT
  • fix: promise issue (#4013) - by @KobeNguyenT
  • fix: seeCssPropertiesOnElements issue with improper condition (#4057) - by @KobeNguyenT

📖 Documentation

  • docs: Update clearCookie documentation for Playwright helper (#4005) - by @Hellosager
  • docs: improve the example code for autoLogin (#4019) - by @KobeNguyenT Screenshot 2023-11-22 at 14 40 11

New Contributors

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.8...3.5.10

3.5.9

5 months ago

❤ī¸ Thanks all to those who contributed to make this release! ❤ī¸

🛩ī¸ Features

  • feat: expose WebElement (#4043) - by @KobeNguyenT
Now we expose the WebElements that are returned by the WebHelper and you could make the subsequence actions on them.

// Playwright helper would return the Locator

I.amOnPage('/form/focus_blur_elements');
const webElements = await I.grabWebElements('#button');
webElements[0].click();
  • feat(playwright): support HAR replaying (#3990) - by @KobeNguyenT
Replaying from HAR

 // Replay API requests from HAR.
 // Either use a matching response from the HAR,
 // or abort the request if nothing matches.
   I.replayFromHar('./output/har/something.har', { url: "*/**/api/v1/fruits" });
   I.amOnPage('https://demo.playwright.dev/api-mocking');
   I.see('CodeceptJS');
[Parameters]
harFilePath [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Path to recorded HAR file
opts [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)? [Options for replaying from HAR](https://playwright.dev/docs/api/class-page#page-route-from-har)
  • feat(playwright): support HAR recording (#3986) - by @KobeNguyenT
A HAR file is an HTTP Archive file that contains a record of all the network requests that are made when a page is loaded. 
It contains information about the request and response headers, cookies, content, timings, and more. 
You can use HAR files to mock network requests in your tests. HAR will be saved to output/har. 
More info could be found here https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har.

...
recordHar: {
    mode: 'minimal', // possible values: 'minimal'|'full'.
    content: 'embed' // possible values:  "omit"|"embed"|"attach".
}
...
  • improvement(playwright): support partial string for option (#4016) - by @KobeNguyenT
await I.amOnPage('/form/select');
await I.selectOption('Select your age', '21-');

🐛 Bug Fixes

  • fix(playwright): proceedSee could not find the element (#4006) - by @hatufacci
  • fix(appium): remove the vendor prefix of 'bstack:options' (#4053) - by @mojtabaalavi
  • fix(workers): event improvements (#3953) - by @KobeNguyenT
Emit the new event: event.workers.result.

CodeceptJS also exposes the env var `process.env.RUNS_WITH_WORKERS` when running tests with run-workers command so that you could handle the events better in your plugins/helpers.

const { event } = require('codeceptjs');

module.exports = function() {
    // this event would trigger the  `_publishResultsToTestrail` when running `run-workers` command
  event.dispatcher.on(event.workers.result, async () => {
    await _publishResultsToTestrail();
  });
  
  // this event would not trigger the  `_publishResultsToTestrail` multiple times when running `run-workers` command
  event.dispatcher.on(event.all.result, async () => {
      // when running `run` command, this env var is undefined
    if (!process.env.RUNS_WITH_WORKERS) await _publishResultsToTestrail();
  });
}
  • fix: ai html updates (#3962) - by @davert
replaced minify library with a modern and more secure fork. Fixes [email protected] Regular Expression Denial of Service vulnerability #3829
AI class is implemented as singleton
refactored heal.js plugin to work on edge cases
add configuration params on number of fixes performed by ay heal
improved recorder class to add more verbose log
improved recorder class to ignore some of errors
  • fix(appium): closeApp supports both Android/iOS (#4046) - by @KobeNguyenT
  • fix: some security vulnerability of some packages (#4045) - by @KobeNguyenT
  • fix: seeAttributesOnElements check condition (#4029) - by @KobeNguyenT
  • fix: waitForText locator issue (#4039) - by @KobeNguyenT
Fixed this error:

locator.isVisible: Unexpected token "s" while parsing selector ":has-text('Were you able to resolve the resident's issue?') >> nth=0"
      at Playwright.waitForText (node_modules\codeceptjs\lib\helper\Playwright.js:2584:79)
  • fix: move to sha256 (#4038) - by @KobeNguyenT
  • fix: respect retries from retryfailedstep plugin in helpers (#4028) - by @KobeNguyenT
Currently inside the _before() of helpers for example Playwright, the retries is set there, however, when retryFailedStep plugin is enabled, the retries of recorder is still using the value from _before() not the value from retryFailedStep plugin.

Fix:

- introduce the process.env.FAILED_STEP_RETIRES which could be access everywhere as the helper won't know anything about the plugin.
- set default retries of Playwright to 3 to be on the same page with Puppeteer.
  • fix: examples in test title (#4030) - by @KobeNguyenT
When test title doesn't have the data in examples:

Feature: Faker examples

  Scenario Outline: Below are the users
    Examples:
      | user   | role |
      | John  | admin |
      | Tim   | client  |

Faker examples --
    [1]  Starting recording promises
    Timeouts: 
  Below are the users {"user":"John","role":"admin"}
  ✔ OK in 4ms

  Below are the users {"user":"Tim","role":"client"}
  ✔ OK in 1ms

When test title includes the data in examples:


Feature: Faker examples

  Scenario Outline: Below are the users - <user> - <role>
    Examples:
      | user   | role |
      | John  | admin |
      | Tim   | client  |


Faker examples --
    [1]  Starting recording promises
    Timeouts: 
  Below are the users - John - admin 
  ✔ OK in 4ms

  Below are the users - Tim - client 
  ✔ OK in 1ms
  • fix: disable retryFailedStep when using with tryTo (#4022) - by @KobeNguyenT
  • fix: locator builder returns error when class name contains hyphen (#4024) - by @KobeNguyenT
  • fix: seeCssPropertiesOnElements failed when font-weight is a number (#4026) - by @KobeNguyenT
  • fix(appium): missing await on some steps of runOnIOS and runOnAndroid (#4018) - by @KobeNguyenT
  • fix(cli): no error of failed tests when using retry with scenario only (#4020) - by @KobeNguyenT
  • fix: set getPageTimeout to 30s (#4031) - by @KobeNguyenT
  • fix(appium): expose switchToContext (#4015) - by @KobeNguyenT
  • fix: promise issue (#4013) - by @KobeNguyenT
  • fix: seeCssPropertiesOnElements issue with improper condition (#4057) - by @KobeNguyenT

📖 Documentation

  • docs: Update clearCookie documentation for Playwright helper (#4005) - by @Hellosager
  • docs: improve the example code for autoLogin (#4019) - by @KobeNguyenT Screenshot 2023-11-22 at 14 40 11

New Contributors

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.8...3.5.9

3.5.8

5 months ago

What's Changed

Full Changelog: https://github.com/codeceptjs/CodeceptJS/compare/3.5.7...3.5.8