Open tansaku opened 2 years ago
I've added:
console.log(`context: ${context}`)
console.log(`args: ${args}`)
which gives me this:
> run(code).then(obj => console.log(obj));
context: undefined
args: describe('tripler', function(){
it('triples 2', function(){
expect(1).to.eql(1)
})
}),
context: [object Promise]
args: data => resolve(data)
Promise { <pending> }
>
context: (e) => {
if (!runnerStart) runnerStart = Date.now();
suiteCount += 1;
suiteStart = Date.now();
if (obj.suite) {
data.push(obj);
obj = {};
}
const { title, parent } = e;
if (parent.title !== "") obj.parent_suite = parent.title;
let parentName = parent.title;
let nextParent = e.parent,
nextTitle,
count = 0;
// Set count based on number of parents
while (nextTitle !== "") {
try {
nextParent = nextParent.parent;
nextTitle = nextParent.title;
count++;
} catch {
break;
}
}
// Set current suite based on title
currentSuite = title;
// Styling aid, suggesting how much to indent by
obj.depth = count;
if (count > nestedLevels) nestedLevels = count;
if (title) obj.suite = title;
// if (parent.title) obj.parent = parent.title;
}
args: [object Object],[object Object]
but I still can't work out what's going wrong:
uncaughtException (from vm2?): TypeError [Error]: Cannot read property 'title' of undefined
at Proxy.<anonymous> (vm.js:89:18)
The vm.js file in mocha-vm only has 35 lines ...
interesting, I appear to now have things working by adding the following clause to runner.js
:
if(typeof(parent) !== 'undefined') {
I'm having all sorts of trouble trying to use mocha-vm as part of another project. I've linked mocha-vm into my project like so:
and I can see it linked up in
node-modules/.package-lock
And I can see mocha-vm in the
node_modules/
directory of my project. If I cd into thenode_modules/mocha-vm/
directory within my project (which is of course just where I've git cloned mocha-vm on my local system) I can run it fine from the node console like so:however if I try from the node console at the root of my project I get this error:
I've been looking at the code specified in the stack trace, e.g.
node_modules/vm2/lib/contextify.js:228
which is:but don't really know where to go from there ...