08-14-2018 19:39
08-14-2018 19:39
Hi,
If anyone is interested in applying TDD and Unit testing in general, let me know your thoughts about the repo in https://github.com/ihassin/fitbit-coachusa, that shows how to do so locally (using your favourite IDE) and then uploading the code to Fitbit Studio; all this in the hope that one day Fitbit will support a CLI to upload projects and releve us from the UI.
Comments welcome, fork it and make it better!
Thanks,
Itamar
08-15-2018 11:37
08-15-2018 11:37
@ihassin: I'll give it a closer look, thanks for sharing. In the meantime, can you add your project in our OSS repository please?
Best Answer08-15-2018 18:00
08-15-2018 18:00
Thank you Fred, I shall add it to that repo under "examples" as showing the bus times is not a true app, but just an example of how to get Jest working with the code.
I am looking forward to your and others' comments about my code as I am not an expert in any of this, just wanted to hack my way in to getting tests running in both dev and Fitbit environments.
Best Answer08-22-2018 18:47 - edited 08-22-2018 18:50
08-22-2018 18:47 - edited 08-22-2018 18:50
Best Answer08-23-2018 06:43
08-23-2018 06:43
@ihassin: I'm happy to tell you that we just release CLI tools.
08-23-2018 06:51
08-23-2018 06:51
Best Answer08-23-2018 06:55
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
08-23-2018 06:55
With the release of our new CLI SDK tools, Jest integration is super simple. Pop the following in a jest.config.js:
module.exports = {
transform: {
".(t|j)sx?": "ts-jest",
},
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
],
testRegex: ".*\\.test\\.(t|j)sx?$",
clearMocks: true,
restoreMocks: true,
testEnvironment: 'node',
};
And add "jest" and "ts-jest" to your devDependencies. "yarn test" should just work then and pick up .test.js files.
As for Fitbit APIs you want to mock out, use jest.mock('file-transfer') or similar, and then your actual application code can remain unmodified.
08-23-2018 14:53
08-23-2018 14:53
Thanks Liam. All good stuff today 🙂
Best Answer