Closed as not planned
Closed as not planned
Description
I have an unusual use case that I have struggled with for over a year, I have run Jasmine standalone through babel to support the Rhino.js engine (somewhere between ES5 and ES6 support). This is now parsing just fine and I have access to Jasmine, I can write a custom boot file!
How do I load up a test from string and have it run?
or
How do I create an entire test suite pragmatically
b. do I need to write a parser myself?
const jasmineRequire = require("./build/jasmine");
this.global = this;
const jasmine = jasmineRequire.core(jasmineRequire);
// Object.assign(this.global, jasmineRequire.patch());
this.global.console = jasmineRequire.patch().console;
this.require = jasmineRequire.patch().require;
// !!Patched!! custom fs and path modules powered by java
const fs = require('fs');
const path = require('path');
// TODO: COPY boot0
Object.assign(this.global, jasmine.getGlobal());
global.jasmine = jasmine;
// it, describe and more
const env = jasmine.getEnv();
const jasmineConfigFile = fs.readFileSync(path.resolve('.', 'spec', 'support', 'jasmine.json'));
const jasmineConfigJSON = JSON.parse(jasmineConfigFile);
env.configure(jasmineConfigJSON);
var jasmineInterface = jasmineRequire.interface(jasmine, env);
// custom more like jest
jasmineInterface.test = jasmineInterface.it;
// const Suite = jasmineInterface.jasmine.Suite;
// A test
const x = jasmineInterface.it('does a thing', function () {
jasmineInterface.expect(true).toBe(false);
});
// ADD TESTS HERE?
env.topSuite().suite_.children.push(Object.assign({
execute: env.execute.bind(null, false, function (args) { console.log(args) }),
}, x));
env.execute(['spec/a.test.js'], function () {
console.log("");
console.log("All tests complete:")
})
.then(function (doneInfo) {
console.log(doneInfo);
});
Metadata
Metadata
Assignees
Labels
No labels