From 5a690867fa31ef3517c882a9b63707cb232560b2 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 11 Feb 2025 16:41:11 +0100 Subject: [PATCH] fix #4848 TS types of methods (Feature|Scenario)Config.config --- .github/CONTRIBUTING.md | 23 +++++++++++++---------- lib/mocha/featureConfig.js | 14 +++++++++++--- lib/mocha/scenarioConfig.js | 11 ++++++++++- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ac35a3875..b5899107e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,13 +7,14 @@ Go over the steps in [this](https://github.com/firstcontributions/first-contribu To start you need: 1. Fork and clone the repo. -2. Run `npm i --force --omit=optional` to install all required libraries +2. Run `npm i --force` to install all required libraries 3. Do the changes. 4. Add/Update Test (if possible) 5. Update documentation -6. Run `npm run docs` if you change the documentation -7. Commit and Push to your fork -8. Make Pull Request +6. Run `npm run def` if you changed the type definitions +7. Run `npm run docs` if you changed the documentation +8. Commit and Push to your fork +9. Make Pull Request To run codeceptjs from this repo use: @@ -27,7 +28,6 @@ To run examples: node bin/codecept.js run -c examples ``` - Depending on a type of change you should do the following. ## Debugging @@ -44,12 +44,12 @@ Please keep in mind that CodeceptJS have **unified API** for Playwright, WebDriv ### Updating Playwright | Puppeteer | WebDriver -*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! * +_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! _ Working test is highly appreciated. To run the test suite you need: -* selenium server + chromedriver -* PHP installed +- selenium server + chromedriver +- PHP installed To launch PHP demo application run: @@ -82,7 +82,7 @@ http://localhost:8000/form/myexample ### Updating REST | ApiDataFactory -*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required!* +_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required!_ Adding a test is highly appreciated. @@ -96,7 +96,7 @@ Edit a test at `test/rest/REST_test.js` or `test/rest/ApiDataFactory_test.js` ## Appium -*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! * +_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! _ It is recommended to run mobile tests on CI. So do the changes, make pull request, see the CI status. @@ -211,6 +211,7 @@ docker-compose run --rm test-helpers test/rest ``` #### Run acceptance tests + To that we provide three separate services respectively for WebDriver, Nightmare and Puppeteer tests: ```sh @@ -235,11 +236,13 @@ And now every command based on `test-helpers` service will use node 9.4.0. The same argument can be passed when building unit and acceptance tests services. ### CI flow + We're currently using a bunch of CI services to build and test codecept in different environments. Here's short summary of what are differences between separate services #### CircleCI + Here we use CodeceptJS docker image to build and execute tests inside it. We start with building Docker container based on Dockerfile present in main project directory. Then we run (in this order) unit tests, all helpers present in diff --git a/lib/mocha/featureConfig.js b/lib/mocha/featureConfig.js index dec3da2da..052b2fbf1 100644 --- a/lib/mocha/featureConfig.js +++ b/lib/mocha/featureConfig.js @@ -3,6 +3,9 @@ * Can inject values and add custom configuration. */ class FeatureConfig { + /** + * @param {CodeceptJS.Suite} suite + */ constructor(suite) { this.suite = suite } @@ -41,12 +44,17 @@ class FeatureConfig { return this } + /** + * @callback FeatureConfigCallback + * @param {CodeceptJS.Suite} suite + * @returns {Object} + */ + /** * Configures a helper. * Helper name can be omitted and values will be applied to first helper. - * - * @param {string|number} helper - * @param {*} obj + * @param {string | Object | FeatureConfigCallback} helper + * @param {Object} [obj] * @returns {this} */ config(helper, obj) { diff --git a/lib/mocha/scenarioConfig.js b/lib/mocha/scenarioConfig.js index 6813e786e..bd73127f6 100644 --- a/lib/mocha/scenarioConfig.js +++ b/lib/mocha/scenarioConfig.js @@ -2,6 +2,9 @@ const { isAsyncFunction } = require('../utils') /** @class */ class ScenarioConfig { + /** + * @param {CodeceptJS.Test} test + */ constructor(test) { this.test = test } @@ -77,10 +80,16 @@ class ScenarioConfig { return this } + /** + * @callback ScenarioConfigCallback + * @param {CodeceptJS.Test} test + * @returns {Object} + */ + /** * Configures a helper. * Helper name can be omitted and values will be applied to first helper. - * @param {string | Object} helper + * @param {string | Object | ScenarioConfigCallback} helper * @param {Object} [obj] * @returns {this} */