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

Tests fail when Code splitting components #24

Open
LanFeusT23 opened this issue Jul 10, 2017 · 5 comments
Open

Tests fail when Code splitting components #24

LanFeusT23 opened this issue Jul 10, 2017 · 5 comments

Comments

@LanFeusT23
Copy link

LanFeusT23 commented Jul 10, 2017

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request

Current behavior
Testing vue components with code splitting is throwing on the import

Minimal reproduction of the problem with instructions
Create a component that async loads other components:

<script>
    const Modal = () => import(/* webpackChunkName: "Modal" */ "@/pages/common/Modal.vue");

    export default {
        name: "TileEditModal",
        components: {
            Modal
        },
        data() {
            return 
        },
        methods: {
            test() {
                return true;
            }
        }
    }
</script>

Create a tests, upon running jest it throws an exception on the import
image

@brenohq
Copy link

brenohq commented Aug 10, 2017

same problem here;

@maxmilton
Copy link

@LanFeusT23 did you come up with a solution for this?

@LanFeusT23
Copy link
Author

Nope, we decided not to code split down to components. We code split on routes only so we don't have this issue. It was ok with us because our modals were really small and code splitting was not gaining much.

@rudionrails
Copy link

@LanFeusT23 here is what you need to do:

yarn add --dev babel-plugin-dynamic-import-node

Then in the .babelrc-file

  "presets" [
    // ...
  ],

  // add env specific configuration
  "env": {
    "test": {
      "plugins": [
        "transform-runtime",
        "dynamic-import-node" // <-- this is the important line
      ]
    }
  }

@garytryan
Copy link

This is still a problem for me. The solution posted by @rudionrails does not work.

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

No branches or pull requests

5 participants