-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Jest HelloWorld Test Fails Out of the Box #1189
Comments
I gotta say the Vue Issue Helper was a really poor experience. I had to turn off my ad blocker to get it to even work. Because the form fields are "fancy" all the times I needed to refresh trying to get it to work resulted in my losing all of my previous input. It also doesn't have an option for the current version of the cli beta9 so I had to change that here. It also didn't help me to determine what project this issue should be filed under. I assume the cli. |
It works for me with uBlock Origin enabled. Also, we are not responsible for and not controlling whatever browser addon you are using.
The input not being "fancy" (I don't even know what you really meant by that) won't retain values if you refresh, it's how browsers work.
This is because the git tags weren't turned into proper GitHub releases for the last 3 betas of vue-cli. It can be fixed in the new issue helper to fetch tags instead of releases.
I would assume that having an issue with vue-cli, you would select the vue-cli project... Also, the issue helper has a repository where you can post the issues you encounter with it. |
Ok, so I shouldn't have polluted this issue with complaining about the issue tool. I'd appreciate focusing on the actual ticket content instead of my difficulties submitting it. If you want I can delete my earlier comment. Just FYI:
|
This only impacts the disabled and checkedness of inputs, not their actual value (you can try in a basic webpage, type something into an input and refresh).
You can open issues here, would be much appreciated. |
the plugin brings its own test script:
Running jest directly doesn't work. This is because the In other words: Everything works as expectd if you follow the steps defined by this plugin. If you leave that path, it's your responsibility to adjust your config to make it work. You could, for example, make the necessary adjustments yourself in |
Please at least read the docs of the plugin you installed before opening issues... They are linked in the welcome page when you first run the app. |
All of the test run methods result in the exact same error:
|
I have been trying to read the documents. This is probably related to changes in babel beta46 which will cause changes in how to hierarchical babel configuration scripts are processed. |
I fixed this by adding the following fragment to "transformIgnorePatterns": [
"node_modules/(?!jest-test)" + "node_modules/(?!(jest-test))"
], Would it be worth doing a PR for this? |
I'm not a fan of change that are not clear to me. What does that do, why does it fix the problem? |
@LinusBorg totally, would need some investigation. My initial understanding is that it is associated with how jest and babel work together. thymikee/jest-preset-angular#66 (comment) has a note on this. |
I've updated CLI (Beta 11 to 15) and created a new virgin project and got this error very first time: npm run test:unit
> tevue@0.1.0 test:unit /whateverFolder/tevue
> vue-cli-service test:unit
FAIL tests/unit/HelloWorld.spec.ts
● Test suite failed to run
/whateverFolder/tevue/src/components/HelloWorld.vue:2
import _classCallCheck from "/whateverFolder/tevue/node_modules/@babel/runtime/helpers/builtin/es6/classCallCheck";
SyntaxError: Unexpected identifier
1 | import { shallowMount } from '@vue/test-utils';
> 2 | import HelloWorld from '@/components/HelloWorld.vue';
3 |
4 | describe('HelloWorld.vue', () => {
5 | it('renders props.msg when passed', () => {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (tests/unit/HelloWorld.spec.ts:2:19)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 4.488s
Ran all test suites.
(node:34241) ExperimentalWarning: The fs.promises API is experimental
ERROR jest exited with code 1. Vue CLI v.3.0.0-beta.15 (vue-router, vuex, stylus, babel, typescript, pwa, unit-jest) The rest is as in package.json. |
Then please open a new issue. We can't track closed ones, and this one was about a similar error, but 6 releases ago. It should have been fixed with this: 1279b3e |
That's the working jest configuration part in "jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"vue"
],
"transform": {
"^.+\\.vue$": "vue-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
"^.+\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!jest-test)"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1"
},
"snapshotSerializers": [
"jest-serializer-vue"
],
"testMatch": [
"<rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))"
]
} Adding the following part did help (@wolfeidau you have a typo in your code, all the stuff right to "transformIgnorePatterns": [
"node_modules/(?!jest-test)"
], |
Can't reproduce on fresh beta.15 installs, using npm/yarn and Node 8/10. Are you on Windows? Please open a separate issue with a reproducible repo because |
Posting here since this was a top hit for me on a Google search. I ran into this issue even after updating all my dependencies to the latest version. To finally fix the issue, I had to switch to yarn. Another thing that worked is spinning up a new app with the cli (with the same options as the problem repo), copying over the Possibly an issue with npm not updating nested dependencies 🤷♂️ |
This problem has happened a couple of times for me when trying to run None of the above suggestions worked for me. I found the following cleared the problem:
Edit: The problem just happened again, it looks like step 2 is unnecessary. |
Version
3.0.0-beta.9
Reproduction link
https://github.com/rgant/vue-helloworld-test-fails
Steps to reproduce
Create new Vue project with Jest unit tests. Run jest.
What is expected?
Initial HelloWorld component test pass
What is actually happening?
Test fails
The text was updated successfully, but these errors were encountered: