Create-react-app: Unsupported key testURL causes troubles for (non-root) sub applications.

Created on 7 Nov 2017  路  7Comments  路  Source: facebook/create-react-app

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鈥檛 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.

bug

Most helpful comment

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"

All 7 comments

/cc @gaearon what do you think about this?

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

Should we set a default testURL based on homepage?

Sounds reasonable to me

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

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"

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

barcher picture barcher  路  3Comments

wereHamster picture wereHamster  路  3Comments

stopachka picture stopachka  路  3Comments

dualcnhq picture dualcnhq  路  3Comments

oltsa picture oltsa  路  3Comments