{"id":13339577,"url":"https://github.com/jmmoser/thingworx-jest","last_synced_at":"2026-05-01T00:31:38.866Z","repository":{"id":84870455,"uuid":"220257939","full_name":"jmmoser/thingworx-jest","owner":"jmmoser","description":"Adaptation of Jest JavaScript Testing Framework for ThingWorx Services","archived":false,"fork":false,"pushed_at":"2020-08-21T03:08:47.000Z","size":198,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-29T21:06:35.063Z","etag":null,"topics":["javascript","jest","test","testing","tests","thingworx","unit","unit-test","unit-testing","unittest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmmoser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-07T14:39:13.000Z","updated_at":"2021-12-14T03:57:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"bfb8a30b-573d-4e76-91a4-8daa6c483bae","html_url":"https://github.com/jmmoser/thingworx-jest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jmmoser/thingworx-jest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmmoser%2Fthingworx-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmmoser%2Fthingworx-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmmoser%2Fthingworx-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmmoser%2Fthingworx-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmmoser","download_url":"https://codeload.github.com/jmmoser/thingworx-jest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmmoser%2Fthingworx-jest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32481553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","jest","test","testing","tests","thingworx","unit","unit-test","unit-testing","unittest"],"created_at":"2024-07-29T19:20:21.975Z","updated_at":"2026-05-01T00:31:38.781Z","avatar_url":"https://github.com/jmmoser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jest JavaScript Testing Framework for ThingWorx Services\n\n### Installation\n1. Create a generic thing and give it a name (e.g. _JestFramework_)\n2. Add a new service on the thing\n3. Give the service a name (e.g. _importScript_)\n3. Set the output of the service to STRING data type\n4. Copy the contents of _jest.js_ and paste into the service script text editor\n5. Save the service\n6. Save the thing\n\n### Usage\nAfter installation, you may reuse this script in any service on any thing/template/shape by including the following snippet at the beginning of the service:\n```javascript\n/** import { expect, describe, test } */\neval(Things['JestFramework'].importScript())(this); // jshint ignore:line\n```\n\nMake sure to set the output of the service to INFOTABLE.\n\n*Note:* I typically create a separate service on each of my things/templates/shapes called *__UNIT_TESTS__ThingName* which runs all of the unit tests for the entity's services.\n\nAdd your unit tests after the snippet:\n```javascript\ndescribe('Echo service', function() {\n  test('Normal input', function() {\n    var input = { a: 1 };\n    expect(me.EchoService(input)).toEqual(input);\n  });\n});\n```\n\nThen execute the service. The result is an infotable with unit test results.\n\n\n### How This Works\nThingWorx does not allow passing functions as arguments to services so all javascript functions need to be defined inside of the service.  To emulate exporting a script, the entire framework is placed inside of a function and [Function.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString) is utillized to get the source code for the function. To emulate importing a script, [eval()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) is utilized to evaluate the source code returned inside of the calling service.  The export of the script source code could be avoided by placing the source string directly in a property and then imported by getting the value of the property instead of calling the service.\n\n### Todo\n- toContain","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmmoser%2Fthingworx-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmmoser%2Fthingworx-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmmoser%2Fthingworx-jest/lists"}