meteor-coverage icon indicating copy to clipboard operation
meteor-coverage copied to clipboard

meteor mocha test coverage not covering export class methods e.g. render()

Open asthajn opened this issue 6 years ago • 0 comments

I am using enzyme for testing. Mount/Shallow test cases are passing but coverage is not increasing.

Expected Behavior

When a test case passes, the coverage should increase.

Current Behavior

Instead only lines are increasing and coverage % is going down

Possible Solution

Is there a possible miss in the configuration file?

Steps to Reproduce (for bugs)

My project is very basic

  1. create meteor app, remove blaze templates, add static-html
  2. Add babel-instanbul to package.json
  3. SET Environment variables: BABEL_ENV=COVERAGE COVERAGE=1 COVERAGE_VERBOSE=1 COVERAGE_APP_FOLDER= TEST_WATCH=1
  4. meteor test --driver-package meteortesting:mocha

Context

Only the global variables and functions are affecting coverage percentage, nothing inside the class is changing coverage. Neither functions, nor statements

Your Environment

Node- v8.11.4 Meteor- 1.9.3 Meteortesting:mocha - 1.1.2 lmieulet:[email protected]

  • Operating System and version: windows server 2012 R2 standard

I cannot copy screenshot due to internet restriction - Here's the code snippet and test case snippets Tests Passing should call testFunc ‣ testFunc();

should render mount ‣ const wrapper = mount(React.createElement(AppView, null)); expect(wrapper.instance().testFunc2()).to.equal(36);


************** Code Snippet ************************ //Function out of the class - gloal context export const testFunc = () => { const a = 2 const b = 34 const c = a+b console.log("c") }  

//class export default class AppView extends Component {   //function that passes test case
testFunc2() { const a = 2 const b = 34 const c = a+b console.log("c") return c }

//mount test cases pass render() { return ( <div className="App"> <Router></Router> ); } }


asthajn avatar Apr 04 '19 10:04 asthajn