question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`blockHosts` test configuration override failing to apply

See original GitHub issue

Current behavior

Hello, I’ve been troubleshooting some strange behavior when leveraging the blockHosts configuration value and overriding the value with the Test Specific Configuration options.

Steps/setup:

  1. blockHosts entry is added to the cypress.json configuration file as a string value (also tried an array with single string)
  2. added an override for a test suite to set the blockHosts entry to null (the default) describe('my suite', {blockHosts: null}, () => {});

Current setup:

// cypress.json
{ "blockHosts": "*.pendo.io" }

// integration/my-suite.test.js
describe('my suite', {blockHosts: ''}, () => {});

The specific my suite test suite continues to block requests to pendo.io.

What I’ve identified thus far:

  1. config is set properly (confirmed the settings GUI)
  2. logged the Cypress.config() value and confirmed that blockHosts is mutated to be an empty string
  3. The x-cypress-matched-blocked-host gets set with the original blockHosts value
Screen Shot 2022-04-20 at 9 50 45 AM

I have tried with various different values for the blockHosts and also tried using the Cypress.config API directly but experienced the same behavior. From my understanding the blockHosts configuration value is not one of the read only configuration options.

Desired behavior

When providing blockHosts as a configuration value for a test suite, it should override the current blockHosts value and the cypress test should respect the new blockHosts value. This same override should be applicable using Cypress.config('blockHosts', '')

Test code to reproduce

https://github.com/cbourdage/cypress-test-tiny/pull/1

Screen Shot 2022-04-20 at 10 34 12 AM

I have been able to replicate this in 2 repos now so you should be able to use any existing tests to try to override the blockHosts configuration option.

Cypress Version

9.3.1

Other

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
cupcakepanda89commented, Aug 10, 2022

I’m on v10.4.0 and have similar issue, blockHosts seems not working correctly.

4reactions
jennifer-shehanecommented, Apr 20, 2022

blockHosts should override the config via a test config override. Looks like a bug. I’m not sure that we have tests for this internally (couldn’t find them quickly).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot: @TestConfiguration Not Overriding Bean During ...
If you want to override a bean definition in your test, use the bean name explicitly as string parameter in your @Bean("beanName") ...
Read more >
Configuration - Cypress Documentation
The number of times to retry a failing test. Can be configured to apply to cypress run or cypress open separately. See Test...
Read more >
E2E Testing with Cypress -03 - Configure Cypress
Tagged with testing, javascript, cypress, automation. ... You can also use environment variables to override configuration values.
Read more >
Testing with Spring Boot's @TestConfiguration Annotation
We will see the use of the `@TestConfiguration` annotation for creating custom beans or overriding specific beans for providing specialized ...
Read more >
Cypress 9.2.0 will throw an error when a user attempts to ...
config () and suite-specific or test-specific configuration overrides. Before. Before version 9.2.0, it was not documented which config options ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found