Git Product home page Git Product logo

wdio-azure-devops-service's Introduction

WDIO Azure Devops Service

version downloads

Publishes WebdriverIO results on Azure DevOps Test Plans.

Core features:

  • Support for Jasmine/Jest/Mocha and Cucumber runtime frameworks
  • Test results are aggregated under the same test run if you are executing more spec(test) files and they are belongs to the same suite
  • Results are reported immediately after single test execution (real-time reporting)
  • Test run is closed after last spec(test) file has been finished
  • Multi suite support

Installation

Install this module locally with the following command to be used as a (dev-)dependency:

npm install --save @gmangiapelo/wdio-azure-devops-service
npm install --save-dev @gmangiapelo/wdio-azure-devops-service

Instructions on how to install WebdriverIO can be found here.

Usage

wdio-azure-devops-service supports NodeJS 8 or higher

wdio-azure-devops-service supports commonjs and esm

Configuration

Since @gmangiapelo/wdio-azure-devops-service is a service, you can set it up in your wdio.conf.js file as follows

import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service";
// wdio.conf.js
exports.config = {
    // ...
    // =====
    // Setup
    // =====
    services: [
        [
              AzureDevopsService,
              {
                  pat: 'u46xjx2ol4px36zg3z565uz52dbvshctlulkhrsecxiamn6nhtwa',
                  organizationUrl: 'https://dev.azure.com/gianlucamangiapelo',
                  projectId: '8b3c68ac-f69d-41c6-bbad-921d8bae9819',
                  planId: 263072,
                  suiteId: 263073,
                  caseIdRegex: '@?[ref](\\d+)',
                  runName: 'FE regression tests for TestPlan',
              },
          ],
    ],
    // ...
};

Test case setup

Your WDIO tests should include the ID of your Azure test case. Make sure your test case IDs are distinct from your test titles:

Mocha style:

// Good:
it("C123 Can authenticate a valid user", ...

// Bad:
it("C123Can authenticate a valid user", ...
it("Can authenticate a valid user C123", ...

Cucumber style:

## Good:
@C123
Scenario Can authenticate a valid user
@c123
Scenario Can authenticate a valid user,

## Bad:
@c123stringTest
Scenario Can authenticate a valid user

Azure DevOps Report Example

This is an example of the results pushed on AZ Test Plans, during a test run AzureDevops Test Plans example


Service Options

pat

The Personal Access token generated in Azure DevOps with API permission set.

Example: "u46xjx2ol4px36zg3z565uz52dbvshctlulkhrsecxiamn6nhtwa"

Type: string

Required: true

organizationUrl

The base url of your Azure DevOps instance.

Example: "https://dev.azure.com/gianlucamangiapelo"

Type: string

Required: true

projectId

The id of the project in Azure DevOps.

To find the projectId use GET {organizationUrl}/_apis/projects?api-version=6.0 and copy the appropriate id.

Example: "3cf7dbc9-cb1e-4240-93f2-9a5960ab3945"

Type: string

Required: true

planId

The test plainId that you can retrieve in Azure DevOps Test Plan section.

Example: 124

Type: integer

Required: true

suiteId

The suiteId that you can retrieve in Azure DevOps Test Plan section, in case of nested suites, get the root suiteId, the service iterates over all the child suites.

Example: 21

Type: integer

Required: true

runName

A descriptive name for the test run.

Example: "FE regression tests run"

Type: string

Required: true

caseIdRegex

Custom regular expression to match the testCaseId from tag or title test case.

Type: string

Default: "@?[cC](\d+)"

Required: false

Author

Gianluca Mangiapelo - github

wdio-azure-devops-service's People

Contributors

gianluca-mangiapelo-deltatre avatar gianlucamangiapelo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wdio-azure-devops-service's Issues

ESM import fails

When I try to use import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service" in V8 with a plain JavaScript project (no TypeScript or Babel to modify node_modules), it fails on internal imports:

Error: Failed to initilialise launcher service unknown: Error: Couldn't initialise "@gmangiapelo/wdio-azure-devops-service".
C:\dev\e2e\node_modules\@gmangiapelo\wdio-azure-devops-service\dist\esm\index.js:1
import AzureDevopsService from './azure-devops-service';

One way I was able to resolve this was:

  1. Change the type of both of your modules to "module" in package.json
  2. Update all file imports to use a full .js path reference as Node's module system is not as forgiving as Babel or TypeScript's.

A simpler way seems to be to simply set your import reference in wdio-azure-devops-service's package.json to also point to the cjs version as with require. This seems to work correctly in an import scenario without having to alter anything further.

OnPrepare and OnComplete hooks are not invoked or executed when WDIO-Azure-devOps-service is initialized

OnPrepare and OnComplete hooks in the class AzureDevopsService are not getting not invoked or executed. Due to which Test run id is not created, hence results are not updated to test plan. Where as if the test run id for test plan is available and inProgress then results are updated to test plan, but test execution history for current test point will not be updated.

gianlucamangiapelo/wdio-azure-devops-service Version: 0.0.11
Jasmine + JS (Node 18.12.1) + WDIO(7.29.1)

image
@gianlucamangiapelo please check and help us with the solution. Please let me know if any additional details are required

Need help, unable to update test cases

Hello, I am hoping that you could give me a hand in getting this service working. I have added the service as per https://webdriver.io/docs/gmangiapelo-wdio-azure-devops-service/ and as far as I can tell have it setup correctly but test cases are not being updated in Azure.

I have looked through issue #1 but have still not been able to get it working. Below is the setup that I have in wdio and Azure. Any help would be greately appreciated, thanks in advance.

PAT setup with the following:
image

wdio.conf.js setup as so:

    services: [
        [driverService], 
        [AzureDevopsService,
            {
            pat: 'pat',
            organizationUrl: 'https://dev.azure.com/org',
            projectId: 'projectid',
            planId: 30584,
            suiteId: 37063,
            caseIdRegex: '@?[cC](\d+)',
            runName: 'AzureDevops Test',
            },
        ],
    ],

When querieng the through Postman I am able to return test cases with no issues using the pat, org, projectId, planId and suiteId
GET https://dev.azure.com/{org}/{projectid}/_apis/test/Plans/30584/suites/37063/testcases?api-version=5.0

"testCase": {
                "id": "37064",
                "url": "https://dev.azure.com/{org}/_apis/wit/workItems/37064",
                "webUrl": "https://dev.azure.com/{org}/web/wi.aspx?pcguid=########-####-####-####-############&id=37064"
            },

Test case setup, I have tried with lower and upper case C:

describe('Test 1', () => {


    it( 'C37064 Test case', async () => {
        
  
    });

});

After running the test Azure is not updated:
image

I have set the logging to:

logLevel: "trace",
outputDir: path.join(__dirname, "/logs"),

But can see no mention of this service in any of the logs.

Please help me by addressing the below mentioned issue

hello @gianlucamangiapelo please help me by addressing the below mentioned issue

i am trying to publish the test results to Azure Devops testcase using your custom service: AzureDevopsService and added that to wdio.config.js file and set all the project, test plan related attributes like below.. also added a test case ID to a test but its not able to publish the test results.. i am quite sure that the azure token and values are perfect as they are working fine via postman.. need to know where I am doing wrong...

services: [
[
'appium',
{
args: {
address: 'localhost',
port: 4724
},
logPath: './'
}
],
[
AzureDevopsService,
{
pat: 'tokenvalue',
organizationUrl: 'https://dev.azure.com/orgid',
projectId: 'projectid',
planId: 6496,
suiteId: 6497,
// caseIdRegex: '@?cC',
caseIdRegex: '(\d+)',
runName: 'Demo',
caseId: 6547
},
]

and in the test script i am using like below:

describe('6547 sample',() => {
it('6547 sample test', async () => {
await driver.pause(10000);
})
})

I am blocked due to this issue, please HELP

Originally posted by @Guru426 in #6 (comment)

Getting import error while using with wdio TS project with module `ESNext`

Getting below error:

`import AzureDevopsService from './azure-devops-service';
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Object.require.extensions. [as .js] (C:\Users\SundaravelLoganathan\Documents\saim_codes\web-revedia\test\node_modules\ts-node\src\index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at cjsLoader (node:internal/modules/esm/translators:356:17)
at ModuleWrap. (node:internal/modules/esm/translators:305:7)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async ConfigParser.addConfigFile (file:///C:/Users/SundaravelLoganathan/Documents/saim_codes/web-revedia/test/node_modules/@wdio/config/build/node/ConfigParser.js:94:36)
at async ConfigParser.initialize (file:///C:/Users/SundaravelLoganathan/Documents/saim_codes/web-revedia/test/node_modules/@wdio/config/build/node/ConfigParser.js:56:13)
at async Launcher.run (file:///C:/Users/SundaravelLoganathan/Documents/saim_codes/web-revedia/test/node_modules/@wdio/cli/build/launcher.js:41:9)
at async Module.run (file:///C:/Users/SundaravelLoganathan/Documents/saim_codes/web-revedia/test/node_modules/@wdio/cli/build/run.js:64:20)`

Attached tsconfig.json file
tsconfig.json

Feature Request: support Jasmine

In jasmine framework the test title is not propagated on the test object, that is used to parse the test case id.

Update the parse function to use also test.description in case the test.title is missing.

Original reference: #4 (comment)

Unable to find the "Pat"

AzureDevopsService,
{
pat: 'u46xjx2ol4px36zg3z565uz52dbvshctlulkhrsecxiamn6nhtwa',
organizationUrl: 'https://dev.azure.com/gianlucamangiapelo',
projectId: '8b3c68ac-f69d-41c6-bbad-921d8bae9819',
planId: 263072,
suiteId: 263073,
caseIdRegex: '@?ref',
runName: 'FE regression tests for TestPlan',
},

actual result is :

Type '{ pat: string; organizationUrl: string; projectId: string; planId: number; suiteId: number; caseIdRegex: string; runName: string; }' is not assignable to type 'ServiceEntry'.
Object literal may only specify known properties, and 'pat' does not exist in type 'HookFunctions | ServiceClass | [string, ServiceOption] | [ServiceClass, ServiceOption]'.ts

Error import EMCA

Hello, I need help, when trying to import the module with import AzureDevopsService from '@gmangiapelo/wdio-azure-devops-service'; i receive this errror
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
ERROR @wdio/config:ConfigParser: Failed loading configuration file: .../wdio.conf.js: Cannot use import statement outside a module
\node_modules@gmangiapelo\wdio-azure-devops-service\dist\esm\index.js:1
import AzureDevopsService from './azure-devops-service';
^^^^^^
I have set in my package.json the "type": "module", but I still receive this error can someone help?

Service is not initialized (Mocha or Cucumber + JS (Node 16.17.0) + WDIO)

Hi! I dealt with the issue that service is not initialized (Mocha or Cucumber + JS (Node 16.17.0) + WDIO).
Analyzed both issues (#1 and #4 ), checked the logs and there are no any data about the service.
I use WDIO example files as a basis for verification and Azure trial subscription, I got appropriate responses using data from Azure API.
My config looks like:

services: ['chromedriver','geckodriver',
  [AzureDevopsService,
  {
      pat: 'pat',
      organizationUrl: 'https://dev.azure.com/org',
      projectId: '8b3c68ac-f69d-41c6-bbad-921d8bae9819',
      planId: 6,
      suiteId: 8,
      caseIdRegex: '@?[ref](https://github.com/gianlucamangiapelo/wdio-azure-devops-service/blob/master/\\d+)',
      runName: 'FE regression tests for TestPlan',
  },

I tried to delete and change this key caseIdRegex, and there was no success.

2022-09-14T18:24:31.827Z INFO @wdio/local-runner: Run worker command: run
2022-09-14T18:24:31.829Z DEBUG @wdio/config:ConfigParser: No compiler found, continue without compiling files
2022-09-14T18:24:31.976Z DEBUG @wdio/local-runner:utils: init remote session
2022-09-14T18:24:31.979Z DEBUG @wdio/utils:initialiseServices: initialise service "chromedriver" as NPM package
2022-09-14T18:24:32.030Z DEBUG @wdio/utils:initialiseServices: initialise service "geckodriver" as NPM package
2022-09-14T18:24:32.071Z DEBUG @wdio/utils:initialiseServices: initialise custom initiated service
2022-09-14T18:24:32.086Z INFO geckodriver: Start Geckodriver (C:\azure-pipelines\node_modules\geckodriver\geckodriver.exe) with args: --log=trace --port=59070

image

Example of scenario:

Feature: The Internet Guinea Pig Website

@C5
Scenario Outline: As a user, I can log into the secure area

Tokens were generated with Full access and with Test Plan management, no changes

Feature Request: option to have test cases in different suiteID

Currently one limitation I found is that I am having to keep all my test cases in one suite. Usually we keep test cases in different suite based on each cucumber feature.

Could you let us know if it's possible to do this ? Either by passing suite number as tag or from a config file ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.