oromis1508 / testcafe-reporter

Test-cafe-html-reporter
MIT License
0 stars 2 forks source link

Logger.step method is not working as expected when we called. #1

Open lakshminagandla opened 4 years ago

lakshminagandla commented 4 years ago

We have used below statement driectly, in our code log messages are printing as expected with console.log, but when we tried with Logger.stop method it is throwing below exception

"await loginpage.login(testdata.userName, testdata.password) Logger.step(1, 'Click the link and do something');"

Exception is:

18 verbose node v12.18.3 19 verbose npm v6.14.6 20 error code ELIFECYCLE 21 error errno 1 22 error com.tech.testcafe@1.0.0 projectSample: testcafe chrome tests/Sample_SmokeTest.js --reporter acd-html-reporter --reportPath test-reports/TestResults1.html 22 error Exit status 1 23 error Failed at the com.tech.testcafe@1.0.0 sample script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

Could you please suggest us how do we import 'Logger class'?

Note: Currently in our testcafe project, we are implementing with javascript, May I know is this report is compatible with javascript project as well.

oromis1508 commented 4 years ago

Before using Logger, you need to import it from the library: var logger = require('node_modules/testcafe-reporter-acd-html-reporter/utils/Logger'); logger.step(123, "I'm doing smth");

If you have some directories in your project, you need to add '../' to import. For example, in wrong_auth.js (see structure below) you need require('../../node_modules/...

test_project

I'm use Typescript for tests and with this language, you can just import it: import { Logger } from 'testcafe-reporter-acd-html-reporter/utils/Logger';

lakshminagandla commented 4 years ago

Hi,

Thanks for acknowledging, in both syntaxes I can see am getting below error message in my smoke.js file when am runnng smoke script.

Cannot find module 'testcafe-reporter-acd-html-reporter/utils/Logger'

Project structure:

SampleProject

Note: When I use below command logger.step() method is not even referenced when I mouse hover on it.

var logger = require('node_modules/testcafe-reporter-acd-html-reporter/utils/Logger');

When I use second syntax, I can see Logger.step() referenced correctly.

import { Logger } from 'testcafe-reporter-acd-html-reporter/utils/Logger';

could you please suggest how do I can use Logger method.

Note: I have installed locally Testcafe-acd-html-reporter plugin

lakshminagandla commented 4 years ago

Getting below error message :

Cannot find module 'testcafe-reporter-acd-html-reporter/utils/Logger'

Please help us to resolve this issue

oromis1508 commented 4 years ago

Hi,

I tried using it in .js file. Yes, there is the error. It's because directive using require in .js files search for files *.js. It's possible to use var logger = require('node_modules/testcafe-reporter-acd-html-reporter/utils/Logger.ts'); But in that case I had an another error, connected with compatibility JS and TS.

I don't have time for finding the solution, I just added Logger.js file to the project (1.2.11 version). Now usual import works correctly in .js and .ts files: import { Logger } from 'testcafe-reporter-acd-html-reporter/utils/Logger'; or var logger = require('testcafe-reporter-acd-html-reporter/utils/Logger');

lakshminagandla commented 4 years ago

Thanks for sharing your views on this issue.

We are currently implemented TestCafe framework with JavaScript language. As per the work around which we done withh testcafe-reporter-acd-html-reporter, seems it wont be suitable for Javascript project. I believe it may will work for Typescript implemented projects.

lakshminagandla2678 commented 4 years ago

Hi,

I have tried to copied the "testcafe-reporter-acd-html-reporter/utils/Logger" file in my project user defined folder and but still we are facing below error message

I have imported like below: mport Logger from '../Services/testcafe-reporter-acd-html-reporter/utils/Logger'; (When we import like this alone, Logger.stop method correctly referenced to Logger class)

Error: Cannot find module '../Services/testcafe-reporter-acd-html-reporter/utils/Logger' Require stack:

Could you please share your suggestions how we should make it work.

As you said if you have Logger.js file, can you share with us. We can see Logger.ts file alone in acd-html-reporter library.

lakshminagandla2678 commented 4 years ago

Log messages are passing into the report wiht help of Logger.js file.

lakshminagandla2678 commented 4 years ago

Please close this issue. Since it is working as expected.