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

fix: add baseUrl to TestConfigOverrides #22445

Merged
merged 5 commits into from Jun 28, 2022
Merged

Conversation

imadx
Copy link
Contributor

@imadx imadx commented Jun 22, 2022

User-facing changelog

Corrected the Typescript types to include baseUrl as a valid test config override option. Fixes #22374 and #22072.

Additional details

The documentation mentions that baseUrl is also configurable and can be changed at run time.
https://docs.cypress.io/guides/references/configuration#Test-Configuration

However, the types are missing baseUrl there for TestConfigOverrides.

Steps to test

Updating baseUrl in a test with Cypress.config("baseUrl", baseUrl); can be used to test the behaviour.

How has the user experience changed?

Before

image

After

There is no typescript warning

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

@imadx imadx requested a review from a team as a code owner June 22, 2022 10:23
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 22, 2022

Thanks for taking the time to open a PR!

@imadx imadx requested review from chrisbreiding and removed request for a team June 22, 2022 10:23
@imadx imadx changed the title add baseUrl to TestConfigOverrides fix: add baseUrl to TestConfigOverrides Jun 22, 2022
@CLAassistant
Copy link

CLAassistant commented Jun 22, 2022

CLA assistant check
All committers have signed the CLA.

@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 22, 2022

Do we still get a warning if we do:

import { defineConfig } from 'cypress'

export default defineConfig({
  baseUrl: 'http://...'
})

This should be invalid. The valid way would be:

import { defineConfig } from 'cypress'

export default defineConfig({
  e2e: {
    baseUrl: 'http://...'
  }
})

It looks like this should still work as expected, just looking to clarify.

Also, this might fix #22072. If it's not too much extra work, could you see if this issue is fixed by your change? (and ideally add a test, if we haven't got one). This should work and be correctly typed, now, too:

it('something', { baseUrl: '...' }, () => {
  // ...
})

We have no way to know at compile time if the current test is e2e or component, so I think we just need to allow this.

@imadx
Copy link
Contributor Author

imadx commented Jun 22, 2022

@imiller thanks for checking!!

Do we still get a warning if we do:

import { defineConfig } from 'cypress'

export default defineConfig({
  baseUrl: 'http://...'
})

This should be invalid. The valid way would be:

import { defineConfig } from 'cypress'

export default defineConfig({
  e2e: {
    baseUrl: 'http://...'
  }
})

👇 This still warns as expected when trying to use baseUrl in the parent level

image


Also, this might fix #22072. If it's not too much extra work, could you see if this issue is fixed by your change? (and ideally add a test, if we haven't got one). This should work and be correctly typed, now, too:

it('something', { baseUrl: '...' }, () => {
  // ...
})

We have no way to know at compile time if the current test is e2e or component, so I think we just need to allow this.

There are existing .js tests for testconfigOverrides from the looks of it.
I just updated the typings-related tests here

Edit: fixed the links to the tests

Copy link
Collaborator

@ryanthemanuel ryanthemanuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and does close #22072 as well. I added that to the description. Thanks for the PR!

@lmiller1990
Copy link
Contributor

@imadx I will get this one merged up, thanks!

@lmiller1990
Copy link
Contributor

I re-pushed the same commit and created a new CI run, and the failing tests are fine: https://github.com/cypress-io/cypress/compare/issue-22445-rerun

The fails here are some unrelated. I'm confident they are not related to this change, I am going to merge this.

@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 27, 2022

I am still finding out the problem with CI. Please wait a bit - I'm going to get this merged as soon as I find out why your branch fails, but my identical fork doesn't.

@imadx
Copy link
Contributor Author

imadx commented Jun 27, 2022

@lmiller1990, is it okay if I rebase from cypress-io:develop and push the changes?
There seem to be quite a few changes from several contributions there.

Or if you have a passing fork, I think it's okay if we can get that merged if someone is waiting on this.

@imadx
Copy link
Contributor Author

imadx commented Jun 27, 2022

I actually have the rebased changes here at #22532
Don't have permission though to get the tests to run from the looks of it.

@lmiller1990
Copy link
Contributor

Thanks, I merged in develop that should have a fix that might help with the CI. Specifically this PR landed #22326. Let's see how it goes.

@cypress
Copy link

cypress bot commented Jun 28, 2022



Test summary

4908 0 59 0Flakiness 0


Run details

Project cypress
Status Passed
Commit 56d8d26
Started Jun 28, 2022 12:28 AM
Ended Jun 28, 2022 12:43 AM
Duration 15:01 💡
OS Linux Debian - 10.11
Browser Electron 100

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@lmiller1990
Copy link
Contributor

We did it, it's passing. Let's merge.

@lmiller1990 lmiller1990 merged commit 5d5574e into cypress-io:develop Jun 28, 2022
@imadx
Copy link
Contributor Author

imadx commented Jun 28, 2022

Nice one. Thanks, @lmiller1990 for getting this through 🚀

lmiller1990 added a commit that referenced this pull request Jun 28, 2022
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
tgriesser added a commit that referenced this pull request Jun 28, 2022
…est-runs-batching

* develop:
  fix: add baseUrl to TestConfigOverrides (#22445)
  fix: distribute files to machines for external contributors. (#22326)
  feat: Display Cypress Dashboard metrics in the Specs Explorer (#21250)
mjhenkes pushed a commit that referenced this pull request Jun 28, 2022
* fix: distribute files to machines for external contributors. (#22326)

* fix: distribute files to machines for external contributors.

* fix path

* fix

* fix glob

* fix

* fix glob pattern spec->cy.

* fix

* echo things.

* test

* use cd.

* fix component tests.

* test

* test

* fix

* refactor

* test distribut-step

fix error
fix
fix
test
TEST

* Revert "test distribut-step"

This reverts commit 15c3606.

* Revert "refactor"

This reverts commit 21a8ad9.

* reduce flake by increasing viewport height

Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>

* fix: add baseUrl to TestConfigOverrides (#22445)

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>

* handle white space when registering ts-node using --require

* update test project

* move config

Co-authored-by: Kukhyeon Heo <sainthkh@naver.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
Co-authored-by: Ishan Madhusanka <ahtimadhusanka@gmail.com>
@lmiller1990
Copy link
Contributor

lmiller1990 commented Jun 28, 2022

It should be out now in 10.3.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants