Shopware 6 Administration: setup component test with JEST - jestjs

I'm looking for a setup documentation for component test with JEST in shopware 6 (with vue utils). This doc is not very helpfull, because the setup instruction is missing.
Maybe is also available a setup for CYPRESS-component tests

Related

Shopware 6 : why to add if condition if (module.hot) in src/Resources/app/storefront/src/main.js in custom plugins

While creating my own storefront JavaScript plugin in shopware 6.3.4.0 latest version, I'm trying to understand concept of following if condition.
if (module.hot) {
module.hot.accept();
}
Does anyone one what is the use of module.hot which is triggering accept() method call. Is it mandatory for storefront JavaScript plugin?
I was refereeing to Shopware 6 Storefront JavaScript plugin but there is no note of it.
That is only used if you use bin/watch-storefront.sh for developing your plugin. That script starts an webpack npm "hot-proxy". With this you see your changes instant in your browser.
It is not mandatory. You can develop your plugin without this feature.
See https://github.com/shopware/platform/blob/f464a9deb1ea93773cff6740df7d0ad09d37e5d1/src/Storefront/Resources/app/storefront/src/main.js#L94 for "reference".

Is it possible to generate the test coverage for a project using Jest which is tested with Chai JS?

I have a project which has various unit tests running successfully using chai js.
Is it possible to use Jest and generate the coverage for this project without rewriting unit tests with Jest JS?
Please provide any documentation to support
It is not possible to do so without rewriting unit tests with Jest JS.
You can search for plugins otherwise
It isn't because Jest has no way to understand your Chai tests.
You will have to migrate them to Jest. As their interfaces are pretty much similar it will not be a painful task.
Airbnb details why and how they do it from Mocha to Jest on a large codebase in this Medium post.
It is possible to migrate from chai using jest-codemods. However you might have to rewrite some configurations and tests(for version compatibility). You can automate changes to your codebase through this.
Please go through these links for further details.
https://jestjs.io/docs/en/migration-guide
https://github.com/skovhus/jest-codemods

Convert Angular 2/3/4/5/6 project to Angular Universal

I have just updated my project to work with Angular 5, and I have got a NodeJS setup on my hosting so I want to create an Angular Universal Application, I would like to convert my current Angular 5 project into a working Angular Universal project that I can setup on my hosting.
The only thing I found on this so far is this;
Convert Angular 4 web app to Angular Universal app
I followed this and It gave me errors, I imagine due to the quick changing nature of Angular that the answer is most likely outdated, so I was wondering the best way to convert it.
Should I just use the starter seed and do the tedious work of adding all my code?
The best way to do this for me personally was add in all my components, services, modules into the universal-starter project, ensure I remove hammerjs or import it properly (for Material 2). I converted most of my components to have .module so I could use their lazy loading (not forgetting to add these paths properly in my routing file and in the static lazy loading path)
It only took a few hours and alot of that was just bug testing/fixing so it was pretty easy all in all.
I had the same issue several weeks ago. There is a Wiki on how to implement Universal into an Angular CLI project : https://github.com/angular/angular-cli/wiki/stories-universal-rendering
Maybe that helps you out.
I found it the easiest to take the current Angular Universal Starter Kit and import all my Modules into a fresh installation. As the new starter is for Angular 5 CLI I hope it's future proof. We will seeā€¦
I wrote a starter kit for MEAN applications with Angular Universal for Angular 5 and you can clone my repository at GitHub here: https://github.com/Stanza987/mean-starter-kit. It provides all the instructions you need to get started. For your specific app, you can just delete the MongoDB part (Mongoose and the out of server.js, node_src/config/database) and npm uninstall mongoose and be able to integrate your project in.

Configure project for Jasmine Test Case using Oracle Weblogic

I am having a web based project which I deploy in weblogic server as EAR for execution. I need to implement Jasmine for unit testing.
I came to know that Jasmine can be executed in NodeJS server but my project has some servlets also as a part of it. So, how can I configure Jasmine to run on oracle weblogic server.
Also, if it is possible by any other means like integrating weblogic with NodeJS (I am not sure about this.) , kindly explain me the process to set up.
I wouldn't try to run your Jasmine tests from WebLogic. That is like saying you want to run your JUnit tests on WebLogic.
JUnit tests are run from the command line in your development environment (often wrapped by the IDE) and also on your CI build agent. Jasmine tests should follow the same pattern. You shouldn't have to go through an entire deploy cycle just to run your unit tests.
I suggest looking at using Karma to run your tests, both locally and on CI.

can I use karma to test page interaction like drag & drop?

I'm evaluating end to end testing of a MEAN stack app. There's a few critical spots in the app where drag and drop (via a directive) is used. I can't find any information about using karma to test this. Is it possible? If not, what library would you recommend?
Yes, Angular comes bundled with e2e testing that can be run via Karma. The angular-seed application is a good example of a project structure that includes both e2e and unit tests. From the project home page:
End to end testing
Angular ships with a baked-in end-to-end test runner that understands
angular, your app and allows you to write your tests with jasmine-like
BDD syntax.
Requires a webserver, node.js + ./scripts/web-server.js or your
backend server that hosts the angular static files.
Check out the end-to-end runner's documentation for more info.
create your end-to-end tests in test/e2e/scenarios.js
serve your project directory with your http/backend server or node.js +
scripts/web-server.js
to run do one of:
open http://localhost:port/test/e2e/runner.html in your browser
run the tests from console with Karma via scripts/e2e-test.sh or script/e2e-test.bat
Also, it should be noted that apparently the Angular team will be replacing this current e2e setup with Protractor at some point in the future.

Resources