Search code examples
javascriptjmetermocha.jsperformance-testingload-testing

How to integrate Jmeter with mocha unit testing?


I've written a simple uint test by Mocha Library.

describe("simple test", async() =>{

     it("first test" , async()=>{

        assert.equal( 1 , 1);
     })
})

Now I need to perform it by JMeter. But I did not find any source for this.

Is it possible to perform the Mocha testing by JMeter or not?

If yes, how?


Solution

  • As per JMeter project main page:

    The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

    Although JMeter supports JavaScript code execution via JSR223 Test Elements

    enter image description here

    You won't be able to run a Mocha-based tests because Nashorn engine is not something compatible with NodeJS and you won't be able to use load() function as Mocha heavily relies on NodeJS

    So the only way to run a Mocha test with JMeter is calling mocha binary from your node_modules folder using OS Process Sampler