CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Not able to see console output while using (codeceptjs run --reporter mocha-junit-reporter) on jenkins

Open ninpop25 opened this issue 9 years ago • 19 comments

What are you trying to achieve?

I have automated my website by using Codeceptjs and have configured Jenkins with TFS for running commands on a set time in night.I am first running (codeceptjs run --steps) and then (codeceptjs run --reporter mocha-junit-reporter) .while running the Reporter command I am not able to see the Step by Step execution of code the way I am able to see with this ((codeceptjs run --steps)) command.

All I see is (I am in helper) as I have used the one in my code.

so anyone please let me know that which command do I need to use for Report generation in which I can see the step by step execution of code

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

# paste output here
```null
I m in helper
I m in helper
WARNING: the "keys" command will be depcrecated soon. Please use a different command in order to avoid failures in your test after updating WebdriverIO.
I m in helper
I m in helper
I m in helper
I m in helper
I m in helper

> Provide test source code if related

```php
// paste test

Details

  • CodeceptJS version:
  • NodeJS Version:
  • Operating System:
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
# paste suite config here

ninpop25 avatar Sep 02 '17 07:09 ninpop25

@ninpop25 Hi!

Step by step execution is provided by custom codecept cli reporter. So when you change it to mocha-junit-reporter you get mocha-junit-reporter output.

I think you should use mocha-multi to use mocha-junit-reporter and codeceptjs cli for reports: http://codecept.io/reports/#multi-reports

Try it and give us feedback!

APshenkin avatar Sep 05 '17 19:09 APshenkin

@APshenkin Hi

Thanks for reply, I tried to use this mohca-multi and for same I added it in my codecept.json file like below.

"mocha": {
    "reporterOptions": {
      "mochaFile": "output/result.xml",
      "codeceptjs-cli-reporter": {
        "stdout": "-",
        "options": {
          "verbose": true,
          "steps": true
        }
      }
    }
  },

After this I ran this command (npm i mocha-multi) into my tests folder and got below error.

`-- [email protected]
  +-- [email protected]
  `-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

Could you please help me out

Note : Earlier I forgot to mentioned that I need to generate XML file through reporter and currently I am doing do by using this (codeceptjs run --reporter mocha-junit-reporter) command that I mentioned earlier.

So please man help me in this

ninpop25 avatar Sep 06 '17 17:09 ninpop25

@ninpop25 Here is step-by-step instruction:

  1. add this to codecept.json:
"mocha": {
        "reporterOptions": {
            "codeceptjs-cli-reporter": {
                "stdout": "-",
                "options": {
                    "verbose": false,
                    "steps": true,
                }
            },
            "mocha-junit-reporter": {
                "stdout": "./output/console.log",
                "options": {
                    "mochaFile": "./output/result.xml"
                }
            }
        }
    },
  1. Install mocha-multi and mocha-junit-reporter
npm i mocha-multi
npm i mocha-junit-reporter
  1. Run tests codeceptjs run --reporter mocha-multi

Hope it helps

APshenkin avatar Sep 08 '17 09:09 APshenkin

@APshenkin

Thanks for prompt reply and great help,I performed above steps but now I am getting below error while running the command (codeceptjs run --reporter mocha-multi),I am sharing the complete snapshot of step by step way I installed 1)Mocha 2)Mocha-Multi 3)Mocha-Junit-Reproter.

==========================

D:\Qdabra-2017\FV Automation\Rahul Code>npm i mocha
[email protected] D:\Qdabra-2017\FV Automation\Rahul Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Code>npm i mocha-multi -g
C:\Users\Daffolap-254\AppData\Roaming\npm
+-- UNMET PEER DEPENDENCY mocha@>=2 <4.0.0
`-- [email protected]

npm WARN [email protected] requires a peer of mocha@>=2 <4.0.0 but none was ins
talled.

D:\Qdabra-2017\FV Automation\Rahul Code>npm i mocha-multi
[email protected] D:\Qdabra-2017\FV Automation\Rahul Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Code>npm i mocha-junit-reporter
[email protected] D:\Qdabra-2017\FV Automation\Rahul Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Code>codeceptjs run --reporter mocha-multi
null

npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Code>npm i mocha-junit-reporter
[email protected] D:\Qdabra-2017\FV Automation\Rahul Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Code>codeceptjs run --reporter mocha-multi
null
**ERROR: Unable to find 'codeceptjs-cli-reporter' reporter**
===========================================

Don't know why I am getting this error in last line.

Please help

ninpop25 avatar Sep 13 '17 19:09 ninpop25

@APshenkin

Today I again tried and performed below steps.

================================

D:\Qdabra-2017\FV Automation\Rahul Latest Code>npm i mocha
[email protected] D:\Qdabra-2017\FV Automation\Rahul Latest Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Latest Code>npm i mocha-multi
[email protected] D:\Qdabra-2017\FV Automation\Rahul Latest Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

D:\Qdabra-2017\FV Automation\Rahul Latest Code>npm i mocha-junit-reporter
[email protected] D:\Qdabra-2017\FV Automation\Rahul Latest Code
`-- [email protected]

npm WARN [email protected] No description
npm WARN [email protected] No repository field.

**Note** : Here I run the reporter command 

D:\Qdabra-2017\FV Automation\Rahul Latest Code>codeceptjs run --reporter mocha-m
ulti
null
CodeceptJS v0.6.3-pre
Using test root "D:\Qdabra-2017\FV Automation\Rahul Latest Code"

**Note** : Here below my test started successfully but its not showing the steps in console and also usually color of tests shows in PINK color but now its showing in White color

Open Anonymous form and submit to dbxl --
 √ Anonymous template test in 39173ms

please help me asap

ninpop25 avatar Sep 14 '17 09:09 ninpop25

@ninpop25 You use old version of Codeceptjs. Please Update to 1.0.2 and it will works)

APshenkin avatar Sep 14 '17 09:09 APshenkin

@APshenkin : Please let me know the command to update the codeceptjs version a I am not able to find same.

Also please let me know that once its updated can we degrade to lower version also?

ninpop25 avatar Sep 14 '17 12:09 ninpop25

@APshenkin : it worked for me on my local system and is showing the steps in console while I am using this command to run the test

Note

When I am configuring everything on my local Jenkins and then running the test by using this command then I am not able to see the steps in console.

Below is the complete screenshot

Console Output

Started by user Rahul Jain
Building in workspace D:\Projects\Jenkins
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url https://bitbucket.org/rahul_daffodil/fvautomation.git # timeout=10
Fetching upstream changes from https://bitbucket.org/rahul_daffodil/fvautomation.git
 > C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Bitbucket credentials
 > C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress https://bitbucket.org/rahul_daffodil/fvautomation.git +refs/heads/*:refs/remotes/origin/*
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 965989d4b18bcd9d69e337697e8d3b8f3ca191d2 (refs/remotes/origin/master)
 > C:\Program Files (x86)\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe checkout -f 965989d4b18bcd9d69e337697e8d3b8f3ca191d2
 > C:\Program Files (x86)\Git\bin\git.exe rev-list 965989d4b18bcd9d69e337697e8d3b8f3ca191d2 # timeout=10
No emails were triggered.
[Jenkins] $ cmd /c call C:\Windows\TEMP\jenkins777158558491238127.bat

D:\Projects\Jenkins>npm i 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
[Jenkins] $ cmd /c call C:\Windows\TEMP\jenkins3050369559463352942.bat

D:\Projects\Jenkins>codeceptjs run fv_anonymousTemplate_test.js --reporter mocha-multi 
null
CodeceptJS v1.0.2
Using test root "D:\Projects\Jenkins"

**Note**  : Below is my test and its not showing the steps and only shows OK when the test is getting Pass.


Open Anonymous form and submit to dbxl --
 Anonymous template test
 √ OK in 36686ms

Please look into this and help me asap

ninpop25 avatar Sep 15 '17 07:09 ninpop25

@ninpop25 please send the package.json and codecept.json files for investigations also Please use https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code when you write stdout or command

APshenkin avatar Sep 15 '17 09:09 APshenkin

@APshenkin : Thanks for prompt reply.please find below code for both files and next time I will keep in mind about formatting rules.

I really appreciate your help so far :)

Codecept.json

{
  "output": "./output",
  "helpers": {
    "WebDriverIO": {
      "url": "https://formsviewertest.azurewebsites.net",
      "browser": "chrome",
      "windowSize":"maximize",
      "restart": "true"
    },
    
    "TabSwitch": {
      "require": "./tabswitch_helper.js"
    }
  },
  "include": {
    "I": "./steps_file.js",
    "loginPagePage": "./pages/loginPage.js",
    "manageCredentialPage": "./pages/manageCredential.js",
    "templatePage": "./pages/template.js"
  },
  "mocha": {
    "reporterOptions": {
        "codeceptjs-cli-reporter": {
            "stdout": "-",
            "options": {
                "verbose": false,
                "steps": true
            }
        },
        "mocha-junit-reporter": {
            "stdout": "./output/console.log",
            "options": {
                "mochaFile": "./output/result.xml"
            }
        }
    }
  },
  "bootstrap": "./config/start_server.js",
  "teardown": "./config/stop_server.js",
  "hooks": [],
  "tests": "**/fv_*_test.js",
  "timeout": 10000,
  "name": "FV"
}

Package.json

{
  "name": "fvautomation",
  "version": "1.0.0",
  "description": "",
  "main": "fv_anonymousTemplate_test.js",
  "dependencies": {
    "codeceptjs-webdriverio": "^1.1.0",
    "mocha": "^3.5.3",
    "mocha-junit-reporter": "^1.13.0",
    "mocha-multi": "^0.11.0",
    "mochawesome": "^2.2.0",
    "selenium-standalone": "^6.4.1",
    "sinon": "^2.3.5"
  },
  "devDependencies": {
    "mocha": "^3.4.1"
  },
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC"
}

ninpop25 avatar Sep 15 '17 09:09 ninpop25

@APshenkin : Hi did you looked upon shared codecept.json and package.json file?

please help me asap and also let me know that where I can appreciate you great help

ninpop25 avatar Sep 15 '17 15:09 ninpop25

@ninpop25 I think that the problem is that you use global codeceptJS and local reporters.

I recommend to do some refactoring:

  1. in package.json:
{
  "name": "fvautomation",
  "version": "1.0.0",
  "description": "",
  "main": "fv_anonymousTemplate_test.js",
  "dependencies": {
    "codeceptjs-webdriverio": "^1.1.0",
    "mocha": "^3.5.3",
    "mocha-junit-reporter": "^1.13.0",
    "mocha-multi": "^0.11.0",
    "mochawesome": "^2.2.0",
    "selenium-standalone": "^6.4.1",
    "sinon": "^2.3.5"
  },
  "devDependencies": {
    "mocha": "^3.4.1"
  },
  "scripts": {
    "test": "mocha",
    "codeceptjs": "codeceptjs run -R mocha-multi"
  },
  "author": "",
  "license": "ISC"
}
  1. Remove global codeceptjs on your machine:

npm remove -g codeceptjs

then in your jenkins flow:

  1. Checkout repo
  2. Install npm deps:

npm install 3. run tests using local codeceptjs by npm script:

npm run codeceptjs

APshenkin avatar Sep 15 '17 15:09 APshenkin

@ninpop25 About

also let me know that where I can appreciate you great help

The best way to appreciate our project is to help us with contributing and share experience of usage in social networks or blogposts :)

APshenkin avatar Sep 15 '17 15:09 APshenkin

@APshenkin : Thank you so much for this great help , it worked for me finally and I am feeling very happy :)

ninpop25 avatar Sep 16 '17 06:09 ninpop25

@APshenkin : Is there any alternative of I.wait(), as in my project code I have used this function in all of my tests and this is making my code slow.

the issue is that in some of my tests if I dont use I.wait() after giving the time then my tests got fail.

I have tried to use Waitforelement and Waitfortext function but they dont help in all tests

ninpop25 avatar Sep 29 '17 05:09 ninpop25

@APshenkin : here is the another scenario in which I need some help.

I.click({ xpath: '(//div[@class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front fv-people-selector-dialog ui-resizable"]//div[@class="buttons search"]//input)[2]' });
I.wait(3);
I.click({ xpath: '//input[@placeholder="Please type to select users"]' });

Notes : now in above code the very first line will click on search button and then a loader will appear and will load the data in some auto populated field.

now in third line I am clicking on that auto populated field and if I am not using the I.wait(3); then the codeceptjs is not able to find the third line element as the loader is getting running after first line code.

I have implemented Smartwait in codecept.json like below

"smartWait": 90000, "timeouts": { "script": 90000, "page load": 90000, "implicit": 90000, "explicit": 90000

Please let me know the solution for this issue Asap.

ninpop25 avatar Sep 29 '17 07:09 ninpop25

@APshenkin : I applied SmartWait in my Codecept.json like below , but the issue is that after implementing it I.attachfile function [I.attachFile("input.dz-hidden-input","TestForms.xsn");] is not working.

"WebDriverIO": { "url": "https://formsviewertest.azurewebsites.net", "browser": "chrome", "windowSize":"maximize", "restart": "true", "smartWait": 90000, "timeouts": { "script": 90000, "page load": 90000, "implicit": 90000, "explicit": 90000 } },

Please help me with these issues on urgent basis

ninpop25 avatar Sep 29 '17 13:09 ninpop25

@APshenkin : Hi Sir-please help me with my latest query

ninpop25 avatar Oct 02 '17 10:10 ninpop25

This questions are not related to current issue. Please create new issues for your questions. Thanks!

APshenkin avatar Oct 18 '17 16:10 APshenkin