Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestLogger: Cannot read property 'replace' of undefined #2554

Closed
hdorgeval opened this issue Jun 25, 2018 · 3 comments
Closed

RequestLogger: Cannot read property 'replace' of undefined #2554

hdorgeval opened this issue Jun 25, 2018 · 3 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.

Comments

@hdorgeval
Copy link

Are you requesting a feature or reporting a bug?

May be a bug

What is the current behavior?

Test is launched throufh testcafe-live
But stops immediately with the following error message:

ERROR: TypeError: Cannot read property 'replace' of undefined

What is the expected behavior?

How would you reproduce the current behavior (if this is a bug)?

import { RequestLogger, t} from 'testcafe';
const url=/\/log/;
const logger = RequestLogger(
  {url, method: 'put'},
  {
     logRequestHeaders: false,
     logRequestBody: true,
     logResponseHeaders: false,
     logResponseBody: false,
     stringifyRequestBody: true,
     stringifyResponseBody: true,
 }
);

fixture('test').requestHooks(logger);

test('request logger issue', async () => {
  await t.debug();
});

test will run when logResponseBody: false is replaced by logResponseBody: true

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

Specify your

  • operating system: windows 10
  • testcafe version: 0.23.0
  • node.js version: v10.1.0
  • npm version: 6.0.1
@AndreyBelym AndreyBelym added STATE: Need clarification An issue lacks information for further research. and removed STATE: Need clarification An issue lacks information for further research. labels Jun 25, 2018
@AndreyBelym
Copy link
Contributor

Hi @hdorgeval, thanks for the feedback! It happened because you had passed stringifyResponseBody: true and logResponseBody: false. You can't stringify a request body, if you don't log it. I think we can throw a more descriptive error in this case, or just ignore the stringifyResponseBody option in the context of this issue: #2555.

@hdorgeval
Copy link
Author

Hi @AndreyBelym, thank you for your feedback. This solves the problem.

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.
Projects
None yet
Development

No branches or pull requests

2 participants