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

Dynamic import doesn't work in tests. #2851

Closed
2 of 5 tasks
lukeromanowicz opened this issue May 3, 2019 · 1 comment
Closed
2 of 5 tasks

Dynamic import doesn't work in tests. #2851

lukeromanowicz opened this issue May 3, 2019 · 1 comment
Assignees
Labels
bug Bug reports P1: Urgent Priority mark - high priority
Milestone

Comments

@lukeromanowicz
Copy link
Contributor

lukeromanowicz commented May 3, 2019

Current behavior

Dynamic import is not supported in unit tests written in javascript (not typescript).

Expected behavior

Dynamic import should work and be mockable just like a regular import.

Steps to reproduce the issue

Create a file called test.js with dynamic import:

export default async () => {
  const isServer = (await import('@vue-storefront/core/helpers')).isServer

  return isServer
}

And a unit test written in javascript:

import testSubject from '../../test'

jest.mock('@vue-storefront/core/helpers', () => ({
  get isServer () {
    return false
  }
}))

describe('test', () => {
  it('should return false', async () => {
    const result = await testSubject()

    expect(result).toBe(false)
  })
})

Can you handle fixing this bug by yourself?

  • YES
  • NO

Which Release Cycle state this refers to? Info for developer.

Pick one option.

  • This is a bug report for test version on https://test.storefrontcloud.io - In this case Developer should create branch from develop branch and create Pull Request 2. Feature / Improvement back to develop.
  • This is a bug report for current Release Candidate version on https://next.storefrontcloud.io - In this case Developer should create branch from release branch and create Pull Request 3. Stabilisation fix back to release.
  • This is a bug report for current Stable version on https://demo.storefrontcloud.io and should be placed in next stable version hotfix - In this case Developer should create branch from hotfix or master branch and create Pull Request 4. Hotfix back to hotfix.
@lukeromanowicz lukeromanowicz added the bug Bug reports label May 3, 2019
@lukeromanowicz lukeromanowicz self-assigned this May 3, 2019
@lukeromanowicz lukeromanowicz added the P1: Urgent Priority mark - high priority label May 3, 2019
@lukeromanowicz lukeromanowicz added this to the 1.9.0 milestone May 3, 2019
@filrak
Copy link
Collaborator

filrak commented May 5, 2019

If it's not there on Monday please change milestone to next one

lukeromanowicz added a commit to lukeromanowicz/vue-storefront that referenced this issue May 6, 2019
patzick added a commit that referenced this issue May 6, 2019
Fix javascript polyfils for unit tests - closes #2851
@pkarw pkarw closed this as completed May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports P1: Urgent Priority mark - high priority
Projects
None yet
Development

No branches or pull requests

3 participants