
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Rajah is a Jasmine 2.0 spec runner for Node.js and Google apps script.
Want to use GAS-Library now? Project key is here.
Version: 2.0.1
Stability: 3 - Stable
Date: 2014-05-09
Changes:
Rajah is a simple Jasmine spec runner, but has 3 faces.
Jasmine spec runner for Node.js.
Jasmine spec runner for Google apps script.
Script Library for Google apps script.
Rajah allows you to test Node.js project files in your command line shell. - (1)
And also allows to compile Node.js project files and spec files into one source file. That source code is executable on Google apps script environment and run all specs like as on your PC. - (2)
Last face of Rajah is Google apps script Library. In this case, Rajah is a thin wrapper of Jasmine. It’s almost same as Jasmine itself, but simple and easy to use. - (3)
Following sections explain those 3 ways to use Rajah / Jasmine 2.0.
Nothing special. It's simple and easy to use jasmine spec runner.
$ npm install -g rajah
$ rajah SPECS [ options ]
SPECS
Spec files or directories.
Options
-m RegExp / --match=RegExp
Only math files in SPECS directories are loaded to run.
--color / --noColor
Use color to report.
-o FILEPATH / --output=FILEPATH
Store result into the file.
[Not implemented yet] -r TYPE / --reporttype=TYPE
It will be 'console' or 'junit'.
This is for codegs user. Need understanding how codegs works first.
Rajah execute codegs to pack your project and spec files with special doGet function.
This doGet function provides spec runner functionality.
You can kick doGet by web IDE, HTTP Request(need to publish as web service), or Other triggers.
For quick understanding, see this sample.
Or
Open gas-console.
Open sample project and run doGet function.
Need to install into project’s local directory.
$ npm install rajah // NO -g option.
When package.json exists, install with --save-dev option.
$ npm install --save-dev rajah
Run Rajah in local Node.js environment
rajah command is in local node_modules/.bin directory.
$ ./node_modules/.bin/rajah SPECS [ options ]
This works as same as above section (Jasmine spec runner for Node.js).
Compile with --codegs option switch
Then, add option switch --codegs and you see merged long source code in your terminal.
-o filepath let Rajah to store source code in that file.
$ ./node_modules/.bin/rajah SPECS [ options ] --codegs -o out.js [ codegs-options ]
Paste to Google apps script file
Create new project for unit testing and import console script library (Project key: MYBwh3izlQThbSz1-36mOjVJodnbMh4p7).
Open Code.gs file and paste compiled code.
Open console
Open gas-console
in onother browser window. >> more about gas-console
Run doGet function
Back to google IDE.
On toolbar, select function doGet and press Run button.
You see result in gas-console window.
doGet functiondoGet function is able to be kicked by 3 ways.
IDE Run / Debug button
Explained in usage section is this pattern.
HTTP request
This is for headless unit testing.
Deploy your unit testing project as a web service.
File > Manage versions... and put version number.Publish > Deploy as web app... and get URL of Latest code.Access that URL. When access by browser, result is displayed in the window.
It's possible to add option values as url query parameters.
[NOT YET IMPLEMENTED] Timer or other triggers
Time trrigered unit testing for health checking.
onComplete option(see below) let you set any function to notify the result or store as you like.
$ ./node_modules/.bin/rajah SPECS [ options ] --codegs -o out.js [ codegs-options ]
-o FILEPATH / --output=FILEPATH
-p PACKAGEFILE / --package=PACKAGEFILE
Package file let rajah know which files should be packed for running specs on the GAS environment.
--stamp=STAMP_STRING
This STAMP_STRING will be sotred into compiled file.
And rajah output STAMP_STRING before any report results when executed in GAS environment.
This is for checking if the result of doGet access is exactly from this source code.
Top of compiled file, config object is defined as below.
var rajahConfig = {
"specs": [
"test/jasmine/jasmine-spec.js"
],
"match": null,
"reportType": null,
"showColor": true,
"stamp": "Fri May 09 2014 14:51:44 GMT+0900 (JST)"
};
These values is handed to rajah by command line option when compile with --codegs option switch.
You can chenge this as you like in GAS online IDE.
When http-access, url query parameters overwrite this(specs will be added).
Project key: MW3WzHQgUPiNsCAKwIwmYtVJodnbMh4p7
Console URL: https://script.google.com/macros/s/AKfycbzZaq3NPqMHYBno7ByxV-bpTbDt6EZ4M_5-kjYXXeQ9HI-k_w8/exec
Open your apps script project.
Goto menu: Resources > Libraries...
Copy & paste project key(above) into Find a Library and press Select button.
rajah will be showed up. select version(chose latest one).
Save button.
Write code
Here's First sample code. You need to call only 2 methods.
rajah.init(this);
function MyFunction() {
// Any spec-code
describe("Rajah", function () {
it("is the best friend of Jasmine.", function () {
expect(rajah.rajah.hasOwnProperty('jasmine')).toBe(true);
});
});
rajah.run();
}
Only 2 methods to call:
rajah.init(this)
At the top of sourcefile, call init method with this argument.
rajah copy Jasmine-interface functions into this object. At the top of sourcefile, this points global scope.
rajah.run()
Execute Jasmine after setup any spec-code.
Jasmine-interface functions setup spec-code but not execute at that timing. run method execute Jasmine.
Run your function
On toolbar, select function you wrote. And then press Run or Debug button.
You see result in gas-console.
rajah.init(scopeObject)
It's necessary to call first. rajah will copy jasmine interface API's(describe, it,..) into scopeObject.
'scopeObject' should be this(global object).
rajah.run(onComplete)
Run rajah and execute jasmine. By default, results are printed to gas-console.
onComplete is callback function called with arguments below.
function onComplete(bool passed, num specs, num failures, num pendings)
rajah.addReporter(reporter)
Just call jasmine original addReporter.
rajah.addConsoleReporter(showColor, print)
Instead of gas-console, rajah report to print function.
function print(string)
gas-console use cache service of google apps script and it take time-cost.
Using this method, you can change it faster on-memory console.var resultString = '';
rajah.addReporter(false, function (str) {
resultSting += str;
});
rajah.run(function () {
console.log(resultStr);
// or Report anyway you like.
});
rajah.jasmine
original jasmine object.
FAQs
Jasmine 2.0 runner for Node.js and Google Apps Script.
We found that rajah demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.