Code coverage Issue while deploying changeset to production - salesforce

I am trying to deploy change set which contains Custom fields, Apex classes and test classes from sandbox to production. While executing all test class in Sandbox, Overall Code coverage is 86%. But while deploying to production through change set, getting error message " Details: Average test coverage across all Apex Classes and Triggers is 27%, at least 75% test coverage is required." Please advice.

Related

Playwright x Docusaurs - Integrate and publish test report

I have a Docusaurus site for documentation, to which I would like to publish the HTML test report from Playwright. These are two project in separate repositories.
A new html report is continuously generated upon each test execution and I want the latest version to be available on docusaurus site.
Any advice on the best way to integrate this in a CI/CD workflow between the two?
Refs:
https://docusaurus.io/
https://playwright.dev/docs/test-reporters#html-reporter

Production build of React application showing trimmed componentStack when I use componentDidCatch

In my react JS web application, I use the error boundary to catch errors in the component tree using the componentDidCatch(error, info) function.
But the error information (info.componentStack) which I receive in the development server and production(build) server are totally different. The development server shows the correct error message. But in the production server I can see the trimmed error message. Please see the below image.
Can you please help to solve this issue?
Do I miss any configuration for the production build to receive the proper error information using error boundary?
try adding displayName to your components like:
SomeComponent.displayName = 'SomeComponent'
this will end up in componentStack
This seems intentional in the production mode of React:
https://reactjs.org/docs/error-boundaries.html#component-stack-traces
As per the docs, it's recommended that you set up an external service to help monitor errors in your production apps.

Detect runtime errors in CodeMirror to test documentation site deploy

I have a React UI library that has a documentation site with interactive examples that run with CodeMirror + Babel.
The examples are written within the library repository itself and are read by the client side JS (CodeMirror) of the documentation site when the page is loaded.
I would like add tests to the project's CI server that runs when pull requests are created in order to guarantee the documentation site examples will run without deploying the documentation site itself.
What would be the best way to go about this?
Could it be implemented within a test framework like Mocha? I'd assume you could setup CodeMirror with text inside of it and then search the DOM for nodes that rendered.
Would a try/catch statement be needed? I've not found a hasError API within CodeMirror. Errors tend to bubble up the into the console and block further rendering on the page.

Apex Lightning upload fail because missing test class

I have EntertainmentController, and `EntertainmentControllerTestClass. Inside test class, I add test method refer to each method in the controller, all of them are empty methods so they all pass when run test. But when I upload to package application, I got the message:
Upload Failed:
No test methods found in the Apex code included in the package. At least 75% test coverage is required.
Apex Tests have to actually test your business classes. Having empty tests serves no purpose. You must write Unit Tests that validate the code in your EntertainmentController class. The Unit Tests must result in 75% of the code in the EntertainmentController being executed without failures during test execution.
Also, when you add your Apex Classes to your package, you have to add both your EntertainmentController and EntertainmentControllerTestClass.
Testing Apex

Is there a code coverage for HTML using Karma when doing angular e2e test?

We can use coverage to see how much javascript code is covered with our unit testing. With e2e testing we are literally testing view components in HTML code against controller. So the question is, is there same code coverage available for how much of HTML DOM elements are covered or touched in our e2e testing? I agree, there is a big difference in the execution path testing and UI testing. but curious.
Thanks
As I know e2e testing use your files served by your web server, for unit test they are served directly by karma, e2e testing is mostly used to be sure your page work like you expect, end-to-end test use your server side and client side. That's why you typically never expected to have 100% e2e coverage because they are more fragile.
So people focus on unit test (testing all edge-cases), and they add e2e test to be sure the behavior of the page works correctly.
You can use istanbul and build the coverage report with karma.
http://gotwarlost.github.io/istanbul/
Or this article : http://lkrnac.net/blog/2014/04/measuring-code-coverage-by-protractor/ sum up how to use protractor e2e to generate coverage report of your e2e tests. Using using this tool : https://github.com/r3b/grunt-protractor-coverage
Hope it's help.

Resources