Skip to content

Commit 135c17f

Browse files
增加测试环境 -chenmy
1 parent 1127941 commit 135c17f

File tree

4 files changed

+144
-3
lines changed

4 files changed

+144
-3
lines changed

karma.conf.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Karma configuration
2+
// Generated on Fri Feb 17 2017 15:57:25 GMT+0800 (中国标准时间)
3+
4+
module.exports = function(config) {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
// frameworks to use
11+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12+
frameworks: ['jasmine','commonjs'],
13+
14+
// list of files patterns to load in the browser
15+
files: [ //include:false为不包含这些文件到浏览器中
16+
17+
//Legacy
18+
{pattern:'src/Legacy/libs/SuperMap_Basic-8.1.1-14426.js',include:false},
19+
{pattern:'src/Legacy/libs/SuperMap_IServer-8.1.1-14426.js',include:false},
20+
{pattern:'src/Legacy/libs/Lang/*.js',include:false},
21+
{pattern:'src/Legacy/theme/default/*.js',include:false},
22+
{pattern:'src/Legacy/theme/default/*.css',include:false},
23+
24+
//Core
25+
'src/Core/base.js',
26+
{pattern:'src/Core/**/*.js',include:false},
27+
28+
//test
29+
{pattern:'test/**/*Spec.js',include:false},
30+
'test/js/test-main.js'
31+
],
32+
33+
34+
// list of files to exclude
35+
exclude: [],
36+
37+
38+
// preprocess matching files before serving them to the browser
39+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
40+
preprocessors: {
41+
'src/Legacy/libs/SuperMap_Basic-8.1.1-14426.js':['commonjs'],
42+
'src/Legacy/libs/SuperMap_IServer-8.1.1-14426.js':['commonjs'],
43+
'src/Legacy/libs/Lang/*.js':['commonjs'],
44+
'src/Legacy/theme/default/*.js':['commonjs'],
45+
'src/Core/base.js':['commonjs'],
46+
'src/Core/**/*.js':['commonjs'],
47+
'src/Core/iServer/*.js':['commonjs',"coverage"],
48+
'test/**/*Spec.js': ['commonjs',]
49+
},
50+
51+
52+
// test results reporter to use
53+
// possible values: 'dots', 'progress'
54+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
55+
reporters: ['progress','coverage'],
56+
57+
coverageReporter: {
58+
type:'html',
59+
dir: 'testCoverage/'
60+
},
61+
62+
63+
// web server port
64+
port: 9876,
65+
66+
67+
// enable / disable colors in the output (reporters and logs)
68+
colors: true,
69+
70+
71+
// level of logging
72+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
73+
logLevel: config.LOG_INFO,
74+
75+
76+
// enable / disable watching file and executing tests whenever any file changes
77+
autoWatch: true,
78+
79+
80+
// start these browsers
81+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
82+
browsers: ['Chrome'],
83+
84+
85+
// Continuous Integration mode
86+
// if true, Karma captures browsers, runs the tests and exits
87+
singleRun: false,
88+
89+
// Concurrency level
90+
// how many browser should be started simultaneous
91+
concurrency: Infinity
92+
})
93+
}

package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,30 @@
1616
"keywords": [
1717
"SuperMap",
1818
"leaflet",
19-
"Openlayers3"
19+
"Openlayers3"
2020
],
2121
"author": "SuperMap",
2222
"license": "Apache-2.0",
2323
"devDependencies": {
24-
"webpack": "^1.14.0",
2524
"commander": "2.9.0",
26-
"shelljs": "0.7.6"
25+
"commonjs": "0.0.1",
26+
"jasmine-core": "^2.5.2",
27+
"karma": "^1.4.1",
28+
"karma-chrome-launcher": "^2.0.0",
29+
"karma-commonjs": "^1.0.0",
30+
"karma-coverage": "^1.1.1",
31+
"karma-jasmine": "^1.1.0",
32+
"karma-jasmine-html-reporter": "^0.2.2",
33+
"shelljs": "0.7.6",
34+
"webpack": "^1.14.0"
2735
},
2836
"dependencies": {
2937
"openlayers": "4.0.0",
3038
"leaflet": "1.0.3"
3139
}
40+
"extract-text-webpack-plugin":{"^1.0.1",
41+
"file-loader":"^0.10.0",
42+
"style-loader":"0.13.1",
43+
"css-loader":"0.26.1"
44+
}
3245
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Created by CMY on 2017/2/15.
3+
*/
4+
5+
describe("GetFeatureByBoundsService",function(){
6+
it("constructor",function(){
7+
var url = "http://www.supermap.com:8090/iserver/services/data-jingjin/rest/data";
8+
var myGetFeaturesByBoundsService = new SuperMap.REST.GetFeaturesByBoundsService(url);
9+
expect(1).toBe(1)
10+
})
11+
})

test/test-main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var allTestFiles = []
2+
var TEST_REGEXP = /(spec|test)\.js$/i
3+
4+
// Get a list of all the test files to include
5+
Object.keys(window.__karma__.files).forEach(function (file) {
6+
if (TEST_REGEXP.test(file)) {
7+
// Normalize paths to RequireJS module names.
8+
// If you require sub-dependencies of test files to be loaded as-is (requiring file extension)
9+
// then do not normalize the paths
10+
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '')
11+
allTestFiles.push(normalizedTestModule)
12+
}
13+
})
14+
15+
require.config({
16+
// Karma serves files under /base, which is the basePath from your config file
17+
baseUrl: '/base',
18+
19+
// dynamically load all test files
20+
deps: allTestFiles,
21+
22+
// we have to kickoff jasmine, as it is asynchronous
23+
callback: window.__karma__.start
24+
})

0 commit comments

Comments
 (0)