I'm having trouble getting any of my Polymer Dart tests to run due to the following error that appears after I run pub run test --pub-serve=8081 -p chrome
00:18 +1 -2: compiling test\markdone_test.dart
Failed to load "test\markdone_test.dart": Reflecting on type 'TodoInput' without capability
dart:_internal wrapException
TodoInput is one of the Polymer Dart components for this project, but I've gotten the same error on other projects I have tried testing.
I have followed the documentation on the pub package for dart-lang/test:
Added listorder_test.dart and listorder_test.html with x-dart-test referencing my dart file
Added an entrypoint under the polymer transformer for test/listorder_test.html
Added the test/pub_serve transformer with $include: test/**_test{.*,}.dart
Am I missing some setup step or annotation/metadata? I've been over the docs for testing and they really only have the one mention of testing Polymer components without much else.
Related
Just a quick disclaimer, I cannot reproduce this on another project, which is why I'm here instead of making an issue on the Github.
Issue
So a quick demo project I made to show a co-worker how to use the Vue test utils, went off the wagon. It doesn't get picked up in the transform part of the jest.config.js.
I made the project with the Vue CLI, using vue create demo-project choosing ESlint and Babel, then running vue add #vue/cli-plugin-unit-jest. Everything went fine, I committed, ran the test command and everything went fine.
So we started testing snapshots, and everything was fine. Next day, come back to the project to keep going, and this is the error I get.
> vue-jest#0.1.0 test:unit .../demo-projects/vue-jest
> vue-cli-service test:unit
FAIL tests/unit/example.spec.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
.../demo-projects/vue-jest/tests/unit/example.spec.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { shallowMount } from '#vue/test-utils';
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.163s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Just running the normal npm run test:unit results in the example.spec.js that comes with the test utils is not babel'ed, and fails in the Node test environment.
Attempted Solutions
Did not work
Deleting node_modules and reinstalling
Deleting package-lock.json, in addition to the above step ( separately done )
Reverting back to the commit when it was working
Checking out to a different branch, deleting all the files that vue add #vue/cli-plugin-unit-jest added, then running the command again to re-create all the files
jest.config.js
tests/ - and all it's files
Worked
Pretty clear what's happening, so in the jest.config.js file, I added the .js file under the transform field.
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.(js|jsx)?$': 'babel-jest' // added .js
},
This solution solves the problem, and properly transforms the example.spec.js
Attempted Recreation
I tried to see if this was a bug by creating another project, running the same steps and it worked just fine. I even copied and pasted all the files from the broken one to the new one, looking for differences in git. It was exactly the same. Which is why I thought it might be node_modules, but it still didn't work.
Uhh
Hopefully this isn't a waste of time for anyone reading since it's not truly a problem. I mainly wanted to have it for anyone who might have the same issue to see that adding the .js extension would solve the problem without having to start over, but also curious if anyone has insight on why this might be happening?
After migrating to AS 3.2 android JUnit test run configuration does not work, all types "All in directory",
"All in package" etc.
I mean it does work, but always claims that:
0 test classes found in package '<default package>'
Process finished with exit code 254
Empty test suite.
using ./gradlew test triggers every test
and every single test can be run by AS using that green play button inside editor (for class or single method)
but not for package, module etc.
How to fix that ?
many thanks
Wojtek
Declare your test classes as public
Fixed in Android Studio 3.2.1
So just update AS to newest version and the problem disappears
I have a big web project with many javascript Jasmine unit tests.
In that web project, i use grunt, karma and jasmine.
Is there any way to launch only one test javascript with grunt with a command line ?
Launching all tests is long, so how to do that without modify my gruntfile.js or my karma-unit.conf.js ??
I tried the following command, but it is more a hack than a real solution :
karma run -- --grep=filteredtestexpr
I am not sure of the best way to specify which test to run from the command line. But it seems like your problem can be solved with the following two pointers:
Change the name of a test from it to iit and karma will run only that test (actually all iit tests).
Change describe to ddescribe to run the entire describe block.
Also, use xit and xdescribe to explicitly exclude tests.
When I run grails war I got the following error
Compiling 30 GSP files for package [appInfo].
| Error GSP Compilation error in file /WEB-INF/plugins/app-info-0.4.3/grails-app/views/appinfo/hibernateEntityInfo.gsp at line 69: Tag [each] missing required attribute [in]
I used
grails 2.2.4
and also I want to know the app-info plugin location in the application
It is the problem with App-info plugin. I also got similar problem . I solved by following way
Clean the application using
grails Clean
then run the application using
grails RunApp
and make sure If you are using sequences in the application do not use mysql because mysql does not support sequences.
I have successfully converted two projects from grails 2.2.4 to 2.4.3. I can run the tests, and run-app both from the grails command line, and within ggts.
Then, I converted it to a maven project, by using create-pom to get an initial pom.xml file. After getting the dependencies right, I can again run the tests and the app from the command line and ggts. But I am getting errors on my unit tests (not spock tests) using 'mvn test'.
The errors look like this:
java.lang.NullPointerException
at grails.test.runtime.GrailsApplicationTestPlugin.createParentContext(GrailsApplicationTestPlugin.groovy:143)
at grails.test.runtime.GrailsApplicationTestPlugin.initGrailsApplication(GrailsApplicationTestPlugin.groovy:96)
at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:327)
at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)
It feels like some kind of setup , or dependency issue.