mirror of
https://github.com/facebook/react.git
synced 2026-02-23 20:23:02 +00:00
Use bin/jsx and browserify to build a jasmine bundle.
This commit is contained in:
@@ -53,7 +53,9 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('build:min', ['jsx:release', 'browserify:min']);
|
||||
grunt.registerTask('build:test', [
|
||||
'jsx:debug',
|
||||
'jsx:jasmine',
|
||||
'jsx:test',
|
||||
'browserify:jasmine',
|
||||
'browserify:test'
|
||||
]);
|
||||
|
||||
|
||||
@@ -76,6 +76,17 @@ var transformer = {
|
||||
after: [simpleBannerify]
|
||||
};
|
||||
|
||||
var jasmine = {
|
||||
entries: [
|
||||
"./build/jasmine/all.js"
|
||||
],
|
||||
requires: {
|
||||
"jasmine": "./build/jasmine/all.js"
|
||||
},
|
||||
outfile: "./build/jasmine.js",
|
||||
debug: false
|
||||
};
|
||||
|
||||
var test = {
|
||||
entries: [
|
||||
"./build/modules/test/all.js",
|
||||
@@ -88,6 +99,7 @@ var test = {
|
||||
|
||||
module.exports = {
|
||||
basic: basic,
|
||||
jasmine: jasmine,
|
||||
test: test,
|
||||
min: min,
|
||||
transformer: transformer
|
||||
|
||||
@@ -11,6 +11,15 @@ var debug = {
|
||||
outputDir: "build/modules"
|
||||
};
|
||||
|
||||
var jasmine = {
|
||||
rootIDs: [
|
||||
"all"
|
||||
],
|
||||
configFile: debug.configFile,
|
||||
sourceDir: "vendor/jasmine",
|
||||
outputDir: "build/jasmine"
|
||||
};
|
||||
|
||||
var test = {
|
||||
rootIDs: rootIDs.concat([
|
||||
"test/all.js",
|
||||
@@ -30,6 +39,7 @@ var release = {
|
||||
|
||||
module.exports = {
|
||||
debug: debug,
|
||||
jasmine: jasmine,
|
||||
test: test,
|
||||
release: release
|
||||
};
|
||||
|
||||
@@ -2,17 +2,8 @@
|
||||
// modules in src/test and to specify an ordering on those modules, since
|
||||
// some still have implicit dependencies on others.
|
||||
|
||||
require("./phantom");
|
||||
require("./console");
|
||||
require("ReactTestUtils");
|
||||
require("reactComponentExpect");
|
||||
require("./diff");
|
||||
require("./PrintReporter");
|
||||
require("./HtmlReporter");
|
||||
require("./ReporterView");
|
||||
require("./SpecView");
|
||||
require("./SuiteView");
|
||||
require("./jasmine-support");
|
||||
require("mocks");
|
||||
require("mock-modules");
|
||||
require("./mock-timers");
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="jasmine.css" />
|
||||
<script src="jasmine.js"></script>
|
||||
<script src="jasmine-html.js"></script>
|
||||
<script src="react-test.js"></script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
jasmine.getEnv().execute();
|
||||
require("jasmine").getEnv().execute();
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -45,10 +45,12 @@ server.listen(port, function(req, res) {
|
||||
break;
|
||||
|
||||
case "jasmine.css":
|
||||
case "jasmine.js":
|
||||
case "jasmine-html.js":
|
||||
file = "../vendor/jasmine/" + file;
|
||||
break;
|
||||
|
||||
case "jasmine.js":
|
||||
file = "../build/" + file;
|
||||
break;
|
||||
}
|
||||
|
||||
if (/\.css$/i.test(file)) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var jasmine = require("./jasmine");
|
||||
|
||||
exports.HtmlReporter =
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
@@ -1,3 +1,4 @@
|
||||
var jasmine = require("./jasmine");
|
||||
var diff = require('./diff');
|
||||
|
||||
var red = '\u001b[1;41m';
|
||||
@@ -54,7 +55,7 @@ PrintReporter.prototype.reportRunnerResults = function(runner) {
|
||||
this.failCount + " fail"
|
||||
].join(" "));
|
||||
|
||||
require("test/phantom").exit(this.failCount);
|
||||
require("./phantom").exit(this.failCount);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var jasmine = require("jasmine");
|
||||
|
||||
jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
@@ -1,3 +1,5 @@
|
||||
var jasmine = require("./jasmine");
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
@@ -1,3 +1,5 @@
|
||||
var jasmine = require("./jasmine");
|
||||
|
||||
jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
38
vendor/jasmine/all.js
vendored
Normal file
38
vendor/jasmine/all.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
require("./phantom");
|
||||
require("./console");
|
||||
|
||||
// TODO Also bundle jasmine.css here.
|
||||
var jasmine = require("./jasmine");
|
||||
require("./jasmine-html");
|
||||
require("./jasmine-support");
|
||||
|
||||
require("./HtmlReporter");
|
||||
require("./PrintReporter");
|
||||
require("./ReporterView");
|
||||
require("./SpecView");
|
||||
require("./SuiteView");
|
||||
|
||||
var env = jasmine.getEnv();
|
||||
env.addReporter(new jasmine.HtmlReporter);
|
||||
env.addReporter(new jasmine.PrintReporter);
|
||||
|
||||
function exposeFrom(obj) {
|
||||
obj.spyOn = jasmine.spyOn;
|
||||
obj.it = jasmine.it;
|
||||
obj.xit = jasmine.xit;
|
||||
obj.expect = jasmine.expect;
|
||||
obj.runs = jasmine.runs;
|
||||
obj.waits = jasmine.waits;
|
||||
obj.waitsFor = jasmine.waitsFor;
|
||||
obj.beforeEach = jasmine.beforeEach;
|
||||
obj.afterEach = jasmine.afterEach;
|
||||
obj.describe = jasmine.describe;
|
||||
obj.xdescribe = jasmine.xdescribe;
|
||||
obj.jasmine = jasmine;
|
||||
return obj;
|
||||
}
|
||||
jasmine.exposeFrom = exposeFrom;
|
||||
var global = Function("return this")();
|
||||
exposeFrom(global);
|
||||
|
||||
module.exports = jasmine;
|
||||
2
vendor/jasmine/jasmine-html.js
vendored
2
vendor/jasmine/jasmine-html.js
vendored
@@ -1,3 +1,5 @@
|
||||
var jasmine = require("./jasmine");
|
||||
|
||||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var global = Function("return this")();
|
||||
var jasmine = global.jasmine;
|
||||
var jasmine = require("./jasmine");
|
||||
var spec = false; // TODO
|
||||
|
||||
// Add some matcher for mock functions
|
||||
@@ -126,9 +125,3 @@ if (typeof WeakMap !== "undefined") {
|
||||
return (mismatchKeys.length == 0 && mismatchValues.length == 0);
|
||||
};
|
||||
}
|
||||
|
||||
var HtmlReporter = require("./HtmlReporter").HtmlReporter;
|
||||
var PrintReporter = require("./PrintReporter").PrintReporter;
|
||||
|
||||
jasmine.getEnv().addReporter(new HtmlReporter);
|
||||
jasmine.getEnv().addReporter(new PrintReporter);
|
||||
26
vendor/jasmine/jasmine.js
vendored
26
vendor/jasmine/jasmine.js
vendored
@@ -1,12 +1,10 @@
|
||||
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
|
||||
|
||||
/**
|
||||
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
var jasmine = {};
|
||||
if (isCommonJS) exports.jasmine = jasmine;
|
||||
exports = module.exports = jasmine;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -480,7 +478,7 @@ jasmine.log = function() {
|
||||
var spyOn = function(obj, methodName) {
|
||||
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
|
||||
};
|
||||
if (isCommonJS) exports.spyOn = spyOn;
|
||||
exports.spyOn = spyOn;
|
||||
|
||||
/**
|
||||
* Creates a Jasmine spec that will be added to the current suite.
|
||||
@@ -498,7 +496,7 @@ if (isCommonJS) exports.spyOn = spyOn;
|
||||
var it = function(desc, func) {
|
||||
return jasmine.getEnv().it(desc, func);
|
||||
};
|
||||
if (isCommonJS) exports.it = it;
|
||||
exports.it = it;
|
||||
|
||||
/**
|
||||
* Creates a <em>disabled</em> Jasmine spec.
|
||||
@@ -511,7 +509,7 @@ if (isCommonJS) exports.it = it;
|
||||
var xit = function(desc, func) {
|
||||
return jasmine.getEnv().xit(desc, func);
|
||||
};
|
||||
if (isCommonJS) exports.xit = xit;
|
||||
exports.xit = xit;
|
||||
|
||||
/**
|
||||
* Starts a chain for a Jasmine expectation.
|
||||
@@ -525,7 +523,7 @@ if (isCommonJS) exports.xit = xit;
|
||||
var expect = function(actual) {
|
||||
return jasmine.getEnv().currentSpec.expect(actual);
|
||||
};
|
||||
if (isCommonJS) exports.expect = expect;
|
||||
exports.expect = expect;
|
||||
|
||||
/**
|
||||
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
|
||||
@@ -535,7 +533,7 @@ if (isCommonJS) exports.expect = expect;
|
||||
var runs = function(func) {
|
||||
jasmine.getEnv().currentSpec.runs(func);
|
||||
};
|
||||
if (isCommonJS) exports.runs = runs;
|
||||
exports.runs = runs;
|
||||
|
||||
/**
|
||||
* Waits a fixed time period before moving to the next block.
|
||||
@@ -546,7 +544,7 @@ if (isCommonJS) exports.runs = runs;
|
||||
var waits = function(timeout) {
|
||||
jasmine.getEnv().currentSpec.waits(timeout);
|
||||
};
|
||||
if (isCommonJS) exports.waits = waits;
|
||||
exports.waits = waits;
|
||||
|
||||
/**
|
||||
* Waits for the latchFunction to return true before proceeding to the next block.
|
||||
@@ -558,7 +556,7 @@ if (isCommonJS) exports.waits = waits;
|
||||
var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
|
||||
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
|
||||
};
|
||||
if (isCommonJS) exports.waitsFor = waitsFor;
|
||||
exports.waitsFor = waitsFor;
|
||||
|
||||
/**
|
||||
* A function that is called before each spec in a suite.
|
||||
@@ -570,7 +568,7 @@ if (isCommonJS) exports.waitsFor = waitsFor;
|
||||
var beforeEach = function(beforeEachFunction) {
|
||||
jasmine.getEnv().beforeEach(beforeEachFunction);
|
||||
};
|
||||
if (isCommonJS) exports.beforeEach = beforeEach;
|
||||
exports.beforeEach = beforeEach;
|
||||
|
||||
/**
|
||||
* A function that is called after each spec in a suite.
|
||||
@@ -582,7 +580,7 @@ if (isCommonJS) exports.beforeEach = beforeEach;
|
||||
var afterEach = function(afterEachFunction) {
|
||||
jasmine.getEnv().afterEach(afterEachFunction);
|
||||
};
|
||||
if (isCommonJS) exports.afterEach = afterEach;
|
||||
exports.afterEach = afterEach;
|
||||
|
||||
/**
|
||||
* Defines a suite of specifications.
|
||||
@@ -602,7 +600,7 @@ if (isCommonJS) exports.afterEach = afterEach;
|
||||
var describe = function(description, specDefinitions) {
|
||||
return jasmine.getEnv().describe(description, specDefinitions);
|
||||
};
|
||||
if (isCommonJS) exports.describe = describe;
|
||||
exports.describe = describe;
|
||||
|
||||
/**
|
||||
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
|
||||
@@ -613,7 +611,7 @@ if (isCommonJS) exports.describe = describe;
|
||||
var xdescribe = function(description, specDefinitions) {
|
||||
return jasmine.getEnv().xdescribe(description, specDefinitions);
|
||||
};
|
||||
if (isCommonJS) exports.xdescribe = xdescribe;
|
||||
exports.xdescribe = xdescribe;
|
||||
|
||||
|
||||
// Provide the XMLHttpRequest class for IE 5.x-6.x:
|
||||
|
||||
Reference in New Issue
Block a user