Testing framework disparity

  • 24 June 2023
  • 2 replies
  • 43 views

Badge +1

I have converted a number of integration projects to CLI projects, using zapier convert.  I’ve noticed that they use mocha for their testing framework:

{
"name": "dummy",
"version": "1.0.1",
"description": "lorem ipsum.",
"main": "index.js",
"scripts": {
"test": "mocha --recursive -t 10000"
},
"engines": {
"node": ">=v14",
"npm": ">=5.6.0"
},
"dependencies": {
"zapier-platform-core": "^7.3.0"
},
"devDependencies": {
"mocha": "^10.2.0",
"should": "^13.2.0"
},
"private": true,
"zapier": {
"convertedByCLIVersion": "12.2.0"
}
}

If I start a new CLI project, using zapier init, it uses jest as its testing framework:

{
"name": ".",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --testTimeout 10000"
},
"dependencies": {
"zapier-platform-core": "14.1.1"
},
"devDependencies": {
"jest": "^26.6.3"
},
"private": true
}

Before I created the CLI project (using zapier init), I updated my version of zapier:

$ zapier -v
* CLI version: 14.1.1
* Node.js version: v20.2.0
* OS info: linux-x64
* `zapier-platform-core` dependency: 14.1.1

Did the recommended testing framework change?

In any case, it would be helpful it you included nock in the devDependencies as an easier way to help with mocking.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 3
Badge +6

Hi @benjamink9 , 

Great catch, thank you for calling this out! 

Yes, starting with v10, we switched to recommending Jest:

https://github.com/zapier/zapier-platform/blob/main/packages/cli/README.md#writing-unit-tests

However, as you mentioned, I see that platform UI integrations are still converted with Mocha as the framework, which is certainly inconsistent. 

I’ve shared this with the platform engineering team so they can investigate.

Also, I definitely agree that nock should be included in devDependencies by default, so I’ve made sure to share this feedback as well.

Thanks again for bringing this to our attention!

Userlevel 3
Badge +6

Hey @benjamink9 , 

Thanks again for bringing this to our attention!

I just wanted to share a quick update: as of the latest release, zapier convert should also now use Jest.

Thanks again!