Skip to content

setupTests.js entry missing after eject #643

Closed
@fcaldera

Description

@fcaldera

This is how the setupFiles section looks after ejecting:

    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],

In previous version:

    "setupFiles": [
      "<rootDir>/config/polyfills.js",
      "<rootDir>/src/setupTests.js"
    ], 

Activity

gaearon

gaearon commented on Sep 14, 2016

@gaearon
Contributor

Which previous version? Can you clarify which versions you refer to?

fcaldera

fcaldera commented on Sep 18, 2016

@fcaldera
Author

I think in v0.4.0 it was working fine Dan.

added this to the 0.4.2 milestone on Sep 18, 2016
gaearon

gaearon commented on Sep 18, 2016

@gaearon
Contributor

I checked, and it’s not a bug.

If src/setupTests.js exists when ejecting, it will be included in setupFiles.
Otherwise it will not.

(If you can reproduce it not being included when it exists please give exact instructions to reproduce, i.e. maybe you use symlinks or your setup is unusual in some other way? If you could put some logs in createJestConfig.js around where it does the file exists check, that would help.)

We can’t include it unconditionally because Jest will (rightly) throw an error about missing file.
We could potentially generate it on eject but I don’t think it’s very important.

I made a small tweak: now is uses a relative path instead of an absolute one after ejecting (d279aa0). But I believe current behavior is correct.

christopherdbull

christopherdbull commented on Oct 15, 2017

@christopherdbull

Could I suggest this being added to the documentation somewhere? Happy to do it if you tell me where. I've just spent the last couple of days bashing my head against the desk wonder why setupTests wasn't running in my ejected app...

dannycalleri

dannycalleri commented on Dec 28, 2017

@dannycalleri
Contributor

Hi @gaearon , I was struggling as @TE-Chris was for this issue.
I think that including unconditionally isn't the right decision, but writing it in the doc would be really helpful, I made a PR here: #3656

I wasted almost one day :( , then I found this thread

locked and limited conversation to collaborators on Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @christopherdbull@gaearon@dannycalleri@fcaldera

        Issue actions

          setupTests.js entry missing after eject · Issue #643 · facebook/create-react-app