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

Unsupported key testURL causes troubles for (non-root) sub applications. #3425

Closed
fdc-viktor-luft opened this issue Nov 7, 2017 · 9 comments

Comments

@fdc-viktor-luft
Copy link

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Yes

Which terms did you search for in User Guide?

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#configuration

Environment

  1. node -v: v8.6.0
  2. npm -v: 5.3.0
  3. yarn --version (if you use Yarn): 1.3.2
  4. npm ls react-scripts (if you haven’t ejected): 1.0.12

Then, specify:

  1. Operating system: Ubuntu 16.04.3 LTS xenial

Steps to Reproduce

  1. Use react-router "Router" with history "createBrowserHistory" where supplied some basename-Property because you would like to deploy your application under a specific path. E.g.: "/app"
  2. Run the Tests like recommended "react-scripts test --env=jsdom"
  3. You will see a bunch warning logs like:
Warning: You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "/" to begin with "/app".

Expected Behavior

I would expect that your "createJestConfig" allows also to override "testURL" property. Then I could override your static value "http://localhost" with "http://localhost/app" to resolve my problem. I do not want to eject and had to patch your "createJestConfig" by one line:

supportedKeys.push('testURL')

Actual Behavior

You do not allow to override the "testURL" property inside the package.json.

@Timer
Copy link
Contributor

Timer commented Dec 8, 2017

/cc @gaearon what do you think about this?

@Timer Timer added this to the 1.x milestone Dec 8, 2017
@gaearon
Copy link
Contributor

gaearon commented Jan 8, 2018

I think we should fix it.. somehow :-)
What are our options?

@Timer
Copy link
Contributor

Timer commented Jan 9, 2018

Should we set a default testURL based on homepage?

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

Sounds reasonable to me

@Timer Timer modified the milestones: 1.x, 2.0.0 Jan 9, 2018
@Timer Timer modified the milestones: 2.0.x, 2.x Sep 26, 2018
@Timer Timer removed this from the 2.x milestone Nov 2, 2018
@pokidovea
Copy link

pokidovea commented Dec 12, 2018

+1 for this fix. There is a strange thing: BrowserRouter doesn't fire such warning. But I need Router...

@dfederico
Copy link

I was able to get around this by just adding --testURL http://localhost/{variable} into my test script in package.json,

ie:

"test": "react-scripts-ts test --env=jsdom --watch --testURL http://localhost/foo"

@Sebdevar
Copy link

I was able to get around this by just adding --testURL http://localhost/{variable} into my test script in package.json,

ie:

"test": "react-scripts-ts test --env=jsdom --watch --testURL http://localhost/foo"

Thanks!!!! I've been looking everywhere for a way to change this configuration without having to extract create-react-app!

@mrmckeb
Copy link
Contributor

mrmckeb commented Jun 16, 2021

Hey @fdc-viktor-luft, have you tried this with the latest version? If this is still an issue, can you open a new issue? Thanks.

@mrmckeb mrmckeb closed this as completed Jun 16, 2021
@fdc-viktor-luft
Copy link
Author

Oh. I totally forgot this issue. Yes, it works perfectly fine 😉

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

No branches or pull requests

7 participants