mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Run node-tests with correct NODE_PATH.
This commit is contained in:
20
gruntfile.js
20
gruntfile.js
@ -353,6 +353,9 @@ module.exports = function(grunt) {
|
|||||||
packApp: {
|
packApp: {
|
||||||
cmd: "npm pack",
|
cmd: "npm pack",
|
||||||
cwd: "__dummy__"
|
cwd: "__dummy__"
|
||||||
|
},
|
||||||
|
mochaNode: {
|
||||||
|
cmd: "grunt simplemocha:node"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
multidest: {
|
multidest: {
|
||||||
@ -381,6 +384,11 @@ module.exports = function(grunt) {
|
|||||||
node: {
|
node: {
|
||||||
src: localCfg.nodeTestsDir + '/**/*.js'
|
src: localCfg.nodeTestsDir + '/**/*.js'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
nodeTests: {
|
||||||
|
NODE_PATH: localCfg.outModulesDir,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -391,6 +399,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.loadNpmTasks("grunt-tslint");
|
grunt.loadNpmTasks("grunt-tslint");
|
||||||
grunt.loadNpmTasks("grunt-multi-dest");
|
grunt.loadNpmTasks("grunt-multi-dest");
|
||||||
grunt.loadNpmTasks("grunt-shell");
|
grunt.loadNpmTasks("grunt-shell");
|
||||||
|
grunt.loadNpmTasks("grunt-env");
|
||||||
grunt.loadNpmTasks("grunt-simple-mocha");
|
grunt.loadNpmTasks("grunt-simple-mocha");
|
||||||
|
|
||||||
var cloneTasks = function(originalTasks, taskNameSuffix)
|
var cloneTasks = function(originalTasks, taskNameSuffix)
|
||||||
@ -521,9 +530,18 @@ module.exports = function(grunt) {
|
|||||||
"get-ready-packages"
|
"get-ready-packages"
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
grunt.registerTask("testEnv", function() {
|
||||||
|
console.log('fafla', process.env.NODE_PATH);
|
||||||
|
//var x = require('xml')
|
||||||
|
//console.log(x);
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask("node-tests", [
|
grunt.registerTask("node-tests", [
|
||||||
"clean:nodeTests",
|
"clean:nodeTests",
|
||||||
"ts:buildNodeTests",
|
"ts:buildNodeTests",
|
||||||
"simplemocha:node",
|
"copy:childPackageFiles",
|
||||||
|
"copy:jsLibs",
|
||||||
|
"env:nodeTests",
|
||||||
|
"exec:mochaNode", //spawn a new process to use the new NODE_PATH
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,24 @@
|
|||||||
import {assert} from "chai";
|
import {assert} from "chai";
|
||||||
|
import {XmlParser, ParserEvent, ParserEventType} from 'xml';
|
||||||
|
//import xml = require('xml');
|
||||||
|
|
||||||
describe("test", () => {
|
describe("xml parser", () => {
|
||||||
it("dummy", () => {
|
it("parses simple element", () => {
|
||||||
assert.equal(1, 2);
|
let attributes = null;
|
||||||
|
let element = null;
|
||||||
|
|
||||||
|
var parser = new XmlParser(function (event: ParserEvent) {
|
||||||
|
switch (event.eventType) {
|
||||||
|
case ParserEventType.StartElement:
|
||||||
|
element = event.elementName;
|
||||||
|
attributes = event.attributes;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
parser.parse("<TextField text='hello' />");
|
||||||
|
|
||||||
|
assert.equal('TextField', element);
|
||||||
|
assert.equal('hello', attributes['text']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"grunt-tslint": "0.4.2",
|
"grunt-tslint": "0.4.2",
|
||||||
"mocha": "2.2.5",
|
"mocha": "2.2.5",
|
||||||
"grunt-simple-mocha": "0.4.0",
|
"grunt-simple-mocha": "0.4.0",
|
||||||
|
"grunt-env": "0.4.4",
|
||||||
"chai": "2.3.0",
|
"chai": "2.3.0",
|
||||||
"typescript": "1.5.0-beta"
|
"typescript": "1.5.0-beta"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user