jasminejsx v0.5.0
Overview
A version of jasmine that works with Adobe ExtendScript. ExtendScript is a JavaScript variant that allows you to create and run scripts that extend Adobe's Creative Suite.
Environment
This has been developed and tested on
- Mac OS X 10.14.5 with Adobe InDesign CC 2019
- Mac OS X 10.14.5 with Adobe InDesign CC 2020
- Mac OS X 10.15.3 with Adobe InDesign CC 2020
All but the command line test/run (described below) should work on other platforms.
This uses an old version of jasmine v2.6 since ExtendScript is so old.
Installation
Simply install it like any other npm package. Nice npm setup tutorial here.
npm install jasminejsxYou may also elect to add it to your package.json as development dependency:
"devDependencies": {
"jasminejsx": "^0.1.0"
}and install with a npm install.
Usage
- Create a
test/specdirectory for your*Spec.jsxfiles. In your
test/folder, create your ownrun.jsxfile that will bootstrap your testing environment. Here's what it should look like:// Define your root path - this will be the folder that contains your node_modules folder var Global = Global || {}; Global.rootPath = new File($.fileName).parent.parent; Global.modulesPath = new File(Global.rootPath + '/node_modules'); // Define an optional Logger to override default // $.evalFile(Global.modulesPath + '/extendscript-logger/index.jsx'); // Global.logger = new Logger(Global.rootPath+'/log/mytestlog.log', 'DEBUG'); //Configuration options //Global.jasminejsx = Global.jasminejsx || {} //Global.jasminejsx.specPath = new File(Global.rootPath + '/test/spec'); //Global.jasminejsx.reportPending = true; //defaults to false //Global.jasminejsx.activateApp = true; //defaults to false //Load the jasminejsx setup //@include '../node_modules/jasminejsx/index.jsx' // Sanity check, you can delete this after you verify your root path is correct. Global.logger.info('Global.rootPath is: ' + Global.rootPath); // Run Jasmine $.evalFile(Global.modulesPath + '/jasminejsx/test/run.jsx');You can run this script in a few ways:
- You can run this through the InDesign Scripts panel if it is linked properly to the
Scripts/Scripts Panel/directory inside your Adobe InDesign application directory. - You can run this from VS Code using Adobe's ExtendScript Debugger. Just create a debug configuration that points to it.
- You can run it from within Adobe ExtendScript Toolkit. Not recommended as future development is not in the works for ESTK.
- From the command line - see below.
- You can run this through the InDesign Scripts panel if it is linked properly to the
If you want to be able to run these test from the command line, link to the
node_modules/jasminejsx/test/runfile. This currently only works with OSX machines as it uses JavaScript for automation to open InDesign and run the tests.ln -s ../node_modules/jasminejsx/test/run test/runRun all tests with
test/runor specific tests withtest/run CalculatorSpec.
Testing
npm test or test/run
Output should look like:
me@host$ test/run
2020-02-25T12:13:22|INFO|***************************
2020-02-25T12:13:22|INFO|Jasmine ExtendScript Runner
2020-02-25T12:13:22|INFO|***************************
2020-02-25T12:13:22|WARN|To prevent odd errors, usually methods not being defined, login into Adobe Creative Cloud and verify all modal dialog boxes are closed. If tests are not running as expected, try restarting the application.
2020-02-25T12:13:23|INFO|Loading all specs in /Users/spyle/projects/jasminejsx/test/spec
2020-02-25T12:13:29|INFO|53 specs, 0 failures, 51 pending specs
2020-02-25T12:13:29|INFO|Finished in 0.035 secondsNPM Release Tasks
- Update
package.jsonversion number npm installto update package lock.npm testto ensure tests pass.- Update
CHANGELOG.mdwith changes since last release. - Check them all into the repository.
git tag -a <version> -m <version>; git push --tagsnpm publishto deploy the release to npm.
Thanks
A big thank you to @tmaslen for the original idea and development of jasminejsx.