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

Cant get jest to cover some .vue files when using --coverage #8236

Closed
franciscouemura opened this issue Oct 21, 2020 · 3 comments
Closed

Cant get jest to cover some .vue files when using --coverage #8236

franciscouemura opened this issue Oct 21, 2020 · 3 comments

Comments

@franciscouemura
Copy link

Hi everybody!
I'm using nuxt to develop a dashboard on the company I work for. Unfortunetly I'm struggling with jest when I run the all tests with the coverage option it doesn't show all of my .vue files. I have the following file structure:

├── base-components
│   ├── AppBar.vue
│   ├── buttons
│   │   ├── IconBackButton.vue
│   │   ├── PrimaryButton.vue
│   │   ├── PrimaryTextButton.vue
│   │   ├── SendEmailButton.vue
│   │   └── tests
│   │   ├── IconBackButton.spec.js
│   │   ├── PrimaryButton.spec.js
│   │   ├── PrimaryTextButton.spec.js
│   │   └── SendEmailButton.spec.js
│   ├── cards
│   │   └── PrimaryCardTitle.vue
│   ├── data-table
│   │   ├── DataTableMenuItem.vue
│   │   ├── DataTableMenu.vue
│   │   ├── DataTable.vue
│   │   ├── index.js
│   │   ├── NoDataAlert.vue
│   │   └── Searchbar.vue
│   ├── dialogs
│   │   ├── BaseDialog.vue
│   │   └── ConfirmDialog.vue
│   ├── FooterComponent.vue
│   ├── inputs
│   │   ├── BaseSelect.vue
│   │   ├── DateSelect.vue
│   │   ├── EmailField.vue
│   │   ├── PasswordConfirmField.vue
│   │   └── PasswordField.vue
│   ├── Loading.vue
│   ├── NavigationDrawer.vue
│   ├── Notification.vue
│   ├── NuxtContent.vue
│   └── toolbars
│   ├── PrimaryToolbar.vue
│   ├── tests
│   │   └── ToolbarIconButton.spec.js
│   ├── ToolbarIconButton.vue
│   ├── ToolbarItem.vue
│   └── ToolbarTitle.vue
├── login
│   ├── LoginButton.vue
│   ├── LoginCard.vue
│   └── LoginForm.vue
├── README.md
├── recover
│   └── RecoverCardText.vue
├── reset-password
│   ├── ResetPasswordCard.vue
│   └── ResetPasswordForm.vue
└── tests
├── Loading.spec.js
└── Notification.spec.js

but on the coverage report I only get the following:

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 14.02 0 16.13 14.02
components/base-components 57.89 100 46.15 57.89
AppBar.vue 0 100 0 0 22
Loading.vue 71.43 100 75 71.43 47-48
NavigationDrawer.vue 0 100 0 0 31-51
Notification.vue 85.71 100 75 85.71 15
components/base-components/buttons 100 100 100 100
IconBackButton.vue 100 100 100 100
PrimaryButton.vue 100 100 100 100
PrimaryTextButton.vue 100 100 100 100
SendEmailButton.vue 100 100 100 100
components/base-components/data-table 0 0 0 0
DataTable.vue 0 100 0 0 26-63
Searchbar.vue 0 0 0 0 19-89
components/base-components/dialogs 0 100 0 0
BaseDialog.vue 0 100 100 0 26
ConfirmDialog.vue 0 100 0 0 22-41
components/base-components/inputs 0 100 0 0
BaseSelect.vue 0 100 0 0 53-103
DateSelect.vue 0 100 0 0 30-59
EmailField.vue 0 100 0 0 25
PasswordConfirmField.vue 0 100 0 0 20
PasswordField.vue 0 100 0 0 20
components/base-components/toolbars 0 100 100 0
PrimaryToolbar.vue 0 100 100 0 13-14
components/login 0 100 0 0
LoginButton.vue 0 100 0 0 10
LoginCard.vue 0 100 100 0 8-9
LoginForm.vue 0 100 0 0 20-43
components/recover 0 100 0 0
RecoverCardText.vue 0 100 0 0 15-32
components/reset-password 0 100 0 0
ResetPasswordCard.vue 0 100 100 0 8-9
ResetPasswordForm.vue 0 100 0 0 20-33
pages 0 0 0 0
index.vue 0 100 100 0 7
login.vue 0 100 100 0 12
recover.vue 0 0 0 0 16-44
reset-password.vue 0 100 100 0 12
store/base-store 0 100 0 0
actions.js 0 0 0 0
getters.js 0 0 0 0
index.js 0 0 0 0
mutations.js 0 0 0 0
state.js 0 100 0 0 1

I have some solutions. the last one was the one of vuejs/vue-jest#217
had no luck.
I'm sending attached to the configs of the project. If somebody could give it a try would be of great value.
Thank you all.

files.zip

@Geminii
Copy link

Geminii commented Oct 30, 2020

Hi @franciscouemura
Can you tell us the vue files which doesn't appear into your coverage ?
And maybe purpose a quick archive to reproduce it ?

Here is a part of my Jest configuration :

  modulePaths: [
    '<rootDir>'
  ],
  moduleDirectories: [
    'node_modules'
  ],
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/$1',
    '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)(\\?inline)?$': 'jest-transform-stub',
    '^~/(.*)$': 'vue-jest'
  }

@stale
Copy link

stale bot commented Dec 4, 2020

Thanks for your contribution to Nuxt!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

@stale stale bot added the stale label Dec 4, 2020
Copy link
Member

@franciscouemura I'm closing this as it's a jest issue. You're welcome to pop into the Nuxt Discord at https://discord.nuxtjs.org, however.

Just in case it's relevant, if a component doesn't have a <script> section, it won't show up in jest coverage.

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

3 participants