Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Store
Commits
6c060f10
Commit
6c060f10
authored
May 04, 2016
by
Foxandxss
Committed by
Ward Bell
May 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: enable testing for rc1
closes issue #86
parent
a93c713a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
128 deletions
+116
-128
app/app.component.spec.ts
app/app.component.spec.ts
+8
-6
karma-test-shim.js
karma-test-shim.js
+64
-81
karma.conf.js
karma.conf.js
+8
-10
wallaby.js
wallaby.js
+36
-31
No files found.
app/app.component.spec.ts
.not.yet
→
app/app.component.spec.ts
View file @
6c060f10
...
...
@@ -5,13 +5,15 @@ import {
expect
,
it
,
iit
,
xit
,
describe
,
ddescribe
,
xdescribe
,
beforeEach
,
beforeEachProviders
,
withProviders
,
async, inject
, TestComponentBuilder
} from '
angular2
/testing';
async
,
inject
}
from
'
@angular/core
/testing
'
;
import { By } from 'angular2/platform/browser';
import { provide } from 'angular2/core';
import { ViewMetadata } from 'angular2/core';
import { PromiseWrapper } from 'angular2/src/facade/promise';
import
{
TestComponentBuilder
}
from
'
@angular/compiler/testing
'
;
import
{
By
}
from
'
@angular/platform-browser
'
;
import
{
provide
}
from
'
@angular/core
'
;
import
{
ViewMetadata
}
from
'
@angular/core
'
;
import
{
PromiseWrapper
}
from
'
@angular/core/src/facade/promise
'
;
//////// SPECS /////////////
...
...
karma-test-shim.js
View file @
6c060f10
/*global jasmine, __karma__, window*/
(
function
()
{
// Error.stackTraceLimit = Infinity;
// /*global jasmine, __karma__, window*/
Error
.
stackTraceLimit
=
Infinity
;
jasmine
.
DEFAULT_TIMEOUT_INTERVAL
=
1000
;
// Cancel Karma's synchronous start,
// we call `__karma__.start()` later, once all the specs are loaded.
__karma__
.
loaded
=
function
()
{
};
// SET THE RUNTIME APPLICATION ROOT HERE
var
appRoot
=
'
app
'
;
// no trailing slash!
__karma__
.
loaded
=
function
()
{
};
// RegExp for client application base path within karma (which always starts 'base\')
var
karmaBase
=
'
^
\
/base
\
/
'
;
// RegEx string for base of karma folders
var
appPackage
=
'
base/
'
+
appRoot
;
//e.g., base/app
var
appRootRe
=
new
RegExp
(
karmaBase
+
appRoot
+
'
\
/
'
);
var
onlyAppFilesRe
=
new
RegExp
(
karmaBase
+
appRoot
+
'
\
/(?!.*
\
.spec
\
.js$)([a-z0-9-_
\
.
\
/]+)
\
.js$
'
);
function
isJsFile
(
path
)
{
return
path
.
slice
(
-
3
)
==
'
.js
'
;
}
var
moduleNames
=
[];
function
isSpecFile
(
path
)
{
return
/
\.
spec
\.
js$/
.
test
(
path
);
}
// Configure systemjs packages to use the .js extension for imports from the app folder
var
packages
=
{};
packages
[
appPackage
]
=
{
defaultExtension
:
false
,
format
:
'
register
'
,
map
:
Object
.
keys
(
window
.
__karma__
.
files
)
.
filter
(
onlyAppFiles
)
// Create local module name mapping to karma file path for app files
// with karma's fingerprint in query string, e.g.:
// './hero.service': '/base/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e'
.
reduce
(
function
(
pathsMapping
,
appPath
)
{
var
moduleName
=
appPath
.
replace
(
appRootRe
,
'
./
'
).
replace
(
/
\.
js$/
,
''
);
pathsMapping
[
moduleName
]
=
appPath
+
'
?
'
+
window
.
__karma__
.
files
[
appPath
];
return
pathsMapping
;
},
{})
}
function
isBuiltFile
(
path
)
{
var
builtPath
=
'
/base/app/
'
;
return
isJsFile
(
path
)
&&
(
path
.
substr
(
0
,
builtPath
.
length
)
==
builtPath
);
}
System
.
config
({
packages
:
packages
});
var
allSpecFiles
=
Object
.
keys
(
window
.
__karma__
.
files
)
.
filter
(
isSpecFile
)
.
filter
(
isBuiltFile
);
// Load our SystemJS configuration.
var
packages
=
{
'
app
'
:
{
main
:
'
main.js
'
,
defaultExtension
:
'
js
'
},
'
rxjs
'
:
{
defaultExtension
:
'
js
'
},
};
// Add angular packages to SystemJS config
[
'
@angular/common
'
,
'
@angular/compiler
'
,
'
@angular/core
'
,
'
@angular/http
'
,
'
@angular/platform-browser
'
,
'
@angular/platform-browser-dynamic
'
,
'
@angular/router
'
,
'
@angular/router-deprecated
'
,
'
@angular/upgrade
'
].
forEach
(
function
(
name
)
{
packages
[
name
]
=
{
main
:
'
index.js
'
,
defaultExtension
:
'
js
'
};});
System
.
config
({
baseURL
:
'
/base
'
,
map
:
{
'
rxjs
'
:
'
node_modules/rxjs
'
,
'
@angular
'
:
'
node_modules/@angular
'
,
'
app
'
:
'
app
'
},
packages
:
packages
});
Promise
.
all
([
System
.
import
(
'
@angular/core/testing
'
),
System
.
import
(
'
@angular/platform-browser-dynamic/testing
'
)
]).
then
(
function
(
providers
)
{
var
testing
=
providers
[
0
];
var
testingBrowser
=
providers
[
1
];
// Configure Angular for the browser and
// with test versions of the platform providers
Promise
.
all
([
System
.
import
(
'
angular2/testing
'
),
System
.
import
(
'
angular2/platform/testing/browser
'
)
])
.
then
(
function
(
results
)
{
var
testing
=
results
[
0
];
var
browser
=
results
[
1
];
testing
.
setBaseTestProviders
(
browser
.
TEST_BROWSER
_PLATFORM_PROVIDERS
,
browser
.
TEST_BROWSER
_APPLICATION_PROVIDERS
);
testingBrowser
.
TEST_BROWSER_DYNAMIC
_PLATFORM_PROVIDERS
,
testingBrowser
.
TEST_BROWSER_DYNAMIC
_APPLICATION_PROVIDERS
);
// Load all spec files
// (e.g. 'base/app/hero.service.spec.js')
}).
then
(
function
()
{
// Finally, load all spec files.
// This will run the tests directly.
return
Promise
.
all
(
Object
.
keys
(
window
.
__karma__
.
files
)
.
filter
(
onlySpecFiles
)
.
map
(
function
(
moduleName
)
{
moduleNames
.
push
(
moduleName
);
allSpecFiles
.
map
(
function
(
moduleName
)
{
return
System
.
import
(
moduleName
);
}));
})
.
then
(
success
,
fail
);
////// Helpers //////
function
onlyAppFiles
(
filePath
)
{
return
onlyAppFilesRe
.
test
(
filePath
);
}
function
onlySpecFiles
(
filePath
)
{
return
/
\.
spec
\.
js$/
.
test
(
filePath
);
}
function
success
()
{
console
.
log
(
'
Spec files loaded:
\n
'
+
moduleNames
.
join
(
'
\n
'
)
+
'
\n
Starting Jasmine testrunner
'
);
__karma__
.
start
();
}
function
fail
(
error
)
{
__karma__
.
error
(
error
.
stack
||
error
);
}
})();
}).
then
(
__karma__
.
start
,
__karma__
.
error
);
karma.conf.js
View file @
6c060f10
...
...
@@ -27,23 +27,21 @@ module.exports = function(config) {
// Polyfills
'
node_modules/es6-shim/es6-shim.js
'
,
'
node_modules/angular2/bundles/angular2-polyfills.js
'
,
//
Zone.js dependencie
s
// Note - do not include zone.js itself or long-stack-trace-zone.js` here as
// they are included already in angular2-polyfills
//
Reflect and Zone.j
s
'
node_modules/reflect-metadata/Reflect.js
'
,
'
node_modules/zone.js/dist/zone.js
'
,
'
node_modules/zone.js/dist/jasmine-patch.js
'
,
'
node_modules/zone.js/dist/async-test.js
'
,
'
node_modules/zone.js/dist/fake-async-test.js
'
,
// RxJs
'
node_modules/rxjs/bundles/Rx.js
'
,
// RxJs.
{
pattern
:
'
node_modules/rxjs/**/*.js
'
,
included
:
false
,
watched
:
false
},
{
pattern
:
'
node_modules/rxjs/**/*.js.map
'
,
included
:
false
,
watched
:
false
},
// Angular 2 itself and the testing library
'
node_modules/angular2/bundles/angular2.js
'
,
'
node_modules/angular2/bundles/router.dev.js
'
,
'
node_modules/angular2/bundles/http.dev.js
'
,
'
node_modules/angular2/bundles/testing.dev.js
'
,
{
pattern
:
'
node_modules/@angular/**/*.js
'
,
included
:
false
,
watched
:
false
},
{
pattern
:
'
node_modules/@angular/**/*.js.map
'
,
included
:
false
,
watched
:
false
},
'
karma-test-shim.js
'
,
...
...
wallaby.js
View file @
6c060f10
...
...
@@ -11,17 +11,15 @@ module.exports = function () {
// Polyfills
{
pattern
:
'
node_modules/es6-shim/es6-shim.js
'
,
instrument
:
false
},
{
pattern
:
'
node_modules/angular2/bundles/angular2-polyfills.js
'
,
instrument
:
false
},
// Zone.js dependencies
// Note - do not include zone.js itself or long-stack-trace-zone.js` here as
// they are included already in angular2-polyfills
// Reflect, Zone.js, and test shims
// Rx.js, Angular 2 itself, and the testing library not here because loaded by systemjs
{
pattern
:
'
node_modules/reflect-metadata/Reflect.js
'
,
instrument
:
false
},
{
pattern
:
'
node_modules/zone.js/dist/zone.js
'
,
instrument
:
false
},
{
pattern
:
'
node_modules/zone.js/dist/jasmine-patch.js
'
,
instrument
:
false
},
{
pattern
:
'
node_modules/zone.js/dist/async-test.js
'
,
instrument
:
false
},
{
pattern
:
'
node_modules/zone.js/dist/fake-async-test.js
'
,
instrument
:
false
},
// Rx.js, Angular 2 itself, and the testing library not here because loaded by systemjs
{
pattern
:
'
app/**/*+(ts|html|css)
'
,
load
:
false
},
{
pattern
:
'
app/**/*.spec.ts
'
,
ignore
:
true
}
],
...
...
@@ -39,38 +37,45 @@ module.exports = function () {
bootstrap
:
function
(
wallaby
)
{
wallaby
.
delayStart
();
var
packages
=
{
'
app
'
:
{
main
:
'
main.js
'
,
defaultExtension
:
'
js
'
},
'
rxjs
'
:
{
defaultExtension
:
'
js
'
},
};
// Add angular packages to SystemJS config
[
'
@angular/common
'
,
'
@angular/compiler
'
,
'
@angular/core
'
,
'
@angular/http
'
,
'
@angular/platform-browser
'
,
'
@angular/platform-browser-dynamic
'
,
'
@angular/router
'
,
'
@angular/router-deprecated
'
,
'
@angular/upgrade
'
].
forEach
(
function
(
name
)
{
packages
[
name
]
=
{
main
:
'
index.js
'
,
defaultExtension
:
'
js
'
};});
System
.
config
({
defaultJSExtensions
:
true
,
packages
:
{
app
:
{
meta
:
{
'
*
'
:
{
scriptLoad
:
true
}
}
}
},
paths
:
{
'
npm:*
'
:
'
node_modules/*
'
},
map
:
{
'
angular2
'
:
'
npm:angular2
'
,
'
rxjs
'
:
'
npm:rxjs
'
}
'
rxjs
'
:
'
node_modules/rxjs
'
,
'
@angular
'
:
'
node_modules/@angular
'
,
'
app
'
:
'
app
'
},
packages
:
packages
});
// Configure Angular for the browser and
// with test versions of the platform providers
Promise
.
all
([
System
.
import
(
'
angular2
/testing
'
),
System
.
import
(
'
angular2/platform/testing/browser
'
)
System
.
import
(
'
@angular/core
/testing
'
),
System
.
import
(
'
@angular/platform-browser-dynamic/testing
'
)
])
.
then
(
function
(
results
)
{
var
testing
=
results
[
0
];
var
browser
=
results
[
1
];
.
then
(
function
(
providers
)
{
var
testing
=
providers
[
0
];
var
testingBrowser
=
providers
[
1
];
testing
.
setBaseTestProviders
(
browser
.
TEST_BROWSER_PLATFORM_PROVIDERS
,
browser
.
TEST_BROWSER_APPLICATION_PROVIDERS
);
testingBrowser
.
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS
,
testingBrowser
.
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);
// Load all spec files
return
Promise
.
all
(
wallaby
.
tests
.
map
(
function
(
specFile
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment