cma-template
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "cma-template", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "> TODO: description", | ||
@@ -26,3 +26,3 @@ "author": "helinjiang <onehlj@qq.com>", | ||
}, | ||
"gitHead": "7844dcb795a3f60c999770a047551226542899af" | ||
"gitHead": "0dd360c9bf4a67083b78233692ed8b51b7e0f1e2" | ||
} |
@@ -7,2 +7,4 @@ { | ||
"build-prod": "webpack --config webpack.prod.config.js", | ||
"use-whistle-dev": "cd DevOps/whistle && npm run use-dev", | ||
"use-whistle-prod": "cd DevOps/whistle && npm run use-prod", | ||
"test:e2e": "node test/run-e2e-test.js", | ||
@@ -9,0 +11,0 @@ "test:e2e:show": "cross-env SHOW_BROWSER=1 npm run test:e2e", |
@@ -29,3 +29,3 @@ const path = require('path'); | ||
* @param {String} [opts.projectRootPath] 项目的根路径 | ||
* @param {String} [opts.mockstarPort] mockstar 端口 | ||
* @param {Number} [opts.mockstarPort] mockstar 端口 | ||
* @param {String} [opts.name] whistle 规则集的名字,会展示在 whistle 管理端 Rules 这个 tab 下 | ||
@@ -64,3 +64,3 @@ */ | ||
* @param {String} [opts.projectRootPath] 项目的根路径 | ||
* @param {String} [opts.mockstarPort] mockstar 端口 | ||
* @param {Number} [opts.mockstarPort] mockstar 端口 | ||
* @param {String} [opts.name] whistle 规则集的名字,会展示在 whistle 管理端 Rules 这个 tab 下 | ||
@@ -67,0 +67,0 @@ */ |
@@ -57,6 +57,18 @@ # create-matman-app 的 mocha 模板 | ||
开发调试时,准备测试环境有多种方式。打开 `https://www.sogou.com/sogou.html` 页面,同时设置浏览器走代理服务器 `http://127.0.0.1:8899`,检查加载情况是否正常。 | ||
开发调试阶段时,准备测试环境可以通过自定义自动化脚本来启动,也可以人工启动。 | ||
##### 2.2.1.1 方式一:人工准备 | ||
> 检查是否已经准备好的办法:可以打开 `https://www.sogou.com/sogou.html` 页面,同时设置浏览器走代理服务器 `http://127.0.0.1:8899`,检查加载情况是否正常。 | ||
##### 2.2.1.1 方式一:自动化脚本准备(推荐) | ||
```bash | ||
# 本地开发版本的自动化测试准备 | ||
$ npm run test:e2e:bootstrap:dev | ||
# 生产版本的自动化测试准备 | ||
$ npm run test:e2e:bootstrap | ||
``` | ||
##### 2.2.1.2 方式二:人工准备 | ||
即按照 2.1 章节提到的第 1-4 步 执行,适合在开发调试时使用,具体来说为: | ||
@@ -71,12 +83,3 @@ | ||
##### 2.2.1.2 方式二:自动化脚本准备 | ||
```bash | ||
# 本地开发版本的自动化测试准备 | ||
$ npm run test:e2e:bootstrap:dev | ||
# 生产版本的自动化测试准备 | ||
$ npm run test:e2e:bootstrap | ||
``` | ||
#### 2.2.2 执行测试文件 | ||
@@ -89,4 +92,40 @@ | ||
## 3. 反馈 | ||
## 3. 设置代理 | ||
本项目提供的 `https://www.sogou.com/sogou.html` 页面并非实际存在页面,我们需要借助代理来访问,通过自定义自动化脚本来动态设置,也可以手动设置。 | ||
### 3.1 方式一:动态设置代理 | ||
推荐使用 [whistle](https://github.com/avwo/whistle) 来设置代理,运行如下命令自动设置代理,具体可以阅读 [DevOps/whistle/README.md](./DevOps/whistle/README.md) 。 | ||
``` | ||
# 开发场景 | ||
$ npm run use-whistle-dev | ||
# 生产环境 | ||
$ npm run use-whistle-prod | ||
``` | ||
### 3.2 方式二:手动设置代理 | ||
也可以自己手动设置,其中 `[project_path]` 为本地项目的绝对路径,需要按实际情况替换。 | ||
场景一: 开发场景,代理如下: | ||
``` | ||
www.sogou.com/cgi-bin/a/b/demo_cgi 127.0.0.1:9527 | ||
www.sogou.com/sogou.html [project_path]/build/sogou.html | ||
www.sogou.com/sogou.dev.bundle.js [project_path]/build/sogou.dev.bundle.js | ||
``` | ||
场景二: 生产环境,代理如下: | ||
``` | ||
www.sogou.com/cgi-bin/a/b/demo_cgi 127.0.0.1:9527 | ||
www.sogou.com/sogou.html [project_path]/build/sogou.html | ||
www.sogou.com/sogou.prod.bundle.js [project_path]/build/sogou.prod.bundle.js | ||
``` | ||
## 4. 反馈 | ||
更多文档请阅读 [官方指南](https://matmanjs.github.io/matman/) ,欢迎给我们 [提issue](https://github.com/matmanjs/matman/issues) 和 [star](https://github.com/matmanjs/matman) 。 |
@@ -1,4 +0,2 @@ | ||
const path = require('path'); | ||
const { E2ERunner } = require('matman-e2e-test'); | ||
const whistle = require('../DevOps/whistle'); | ||
const { createE2ERunner, prepareSUT } = require('./e2e.config'); | ||
@@ -9,46 +7,19 @@ const bootstrapMockstarPort = 9527 || process.env.MOCKSTAR_PORT; | ||
(async () => { | ||
const WORKSPACE_PATH = path.join(__dirname, '../'); | ||
const OUTPUT_PATH = path.join(__dirname, '../.matman_output'); | ||
// 创建 E2ERunner | ||
const e2eRunner = await createE2ERunner(); | ||
const e2eRunner = new E2ERunner({ | ||
workspacePath: WORKSPACE_PATH, | ||
outputPath: OUTPUT_PATH, | ||
}); | ||
// 开始启动 | ||
// 设置启动 | ||
await e2eRunner.start(); | ||
// 构建项目 | ||
await e2eRunner.buildProject('npx cross-env ENABLE_E2E_TEST=1 npm run build-dev', { | ||
cwd: WORKSPACE_PATH, | ||
}); | ||
// 启动 mockstar | ||
const mockstarAppPath = path.join(WORKSPACE_PATH, './DevOps/mockstar-app'); | ||
const mockstarPort = await e2eRunner.startMockstar(mockstarAppPath, { port: bootstrapMockstarPort }); | ||
// 启动 whistle | ||
const whistlePort = await e2eRunner.startWhistle({ | ||
port: bootstrapWhistlePort, | ||
// 测试之前准备环境 | ||
const prepareSUTResult = await prepareSUT(e2eRunner, { | ||
mockstarPort: bootstrapMockstarPort, | ||
whistlePort: bootstrapWhistlePort, | ||
useCurrentStartedWhistle: true, | ||
getWhistleRules: () => { | ||
return whistle.getDevRules({ | ||
projectRootPath: WORKSPACE_PATH, | ||
shouldUseMockstar: true, | ||
mockstarPort, | ||
}); | ||
}, | ||
isBuildDev: true | ||
}); | ||
// 启动 matman | ||
const matmanAppPath = path.join(WORKSPACE_PATH, './DevOps/matman-app'); | ||
await e2eRunner.startMatman(matmanAppPath); | ||
// debug 日志 | ||
console.log({ | ||
bootstrapMockstarPort, | ||
bootstrapWhistlePort, | ||
mockstarPort, | ||
whistlePort, | ||
}); | ||
console.log(prepareSUTResult); | ||
console.log(e2eRunner); | ||
})(); |
@@ -1,4 +0,2 @@ | ||
const path = require('path'); | ||
const { E2ERunner } = require('matman-e2e-test'); | ||
const whistle = require('../DevOps/whistle'); | ||
const { createE2ERunner, prepareSUT } = require('./e2e.config'); | ||
@@ -9,46 +7,18 @@ const bootstrapMockstarPort = 9527 || process.env.MOCKSTAR_PORT; | ||
(async () => { | ||
const WORKSPACE_PATH = path.join(__dirname, '../'); | ||
const OUTPUT_PATH = path.join(__dirname, '../.matman_output'); | ||
// 创建 E2ERunner | ||
const e2eRunner = await createE2ERunner(); | ||
const e2eRunner = new E2ERunner({ | ||
workspacePath: WORKSPACE_PATH, | ||
outputPath: OUTPUT_PATH, | ||
}); | ||
// 开始启动 | ||
// 设置启动 | ||
await e2eRunner.start(); | ||
// 构建项目 | ||
await e2eRunner.buildProject('npx cross-env ENABLE_E2E_TEST=1 npm run build-prod', { | ||
cwd: WORKSPACE_PATH, | ||
}); | ||
// 启动 mockstar | ||
const mockstarAppPath = path.join(WORKSPACE_PATH, './DevOps/mockstar-app'); | ||
const mockstarPort = await e2eRunner.startMockstar(mockstarAppPath, { port: bootstrapMockstarPort }); | ||
// 启动 whistle | ||
const whistlePort = await e2eRunner.startWhistle({ | ||
port: bootstrapWhistlePort, | ||
// 测试之前准备环境 | ||
const prepareSUTResult = await prepareSUT(e2eRunner, { | ||
mockstarPort: bootstrapMockstarPort, | ||
whistlePort: bootstrapWhistlePort, | ||
useCurrentStartedWhistle: true, | ||
getWhistleRules: () => { | ||
return whistle.getProdRules({ | ||
projectRootPath: WORKSPACE_PATH, | ||
shouldUseMockstar: true, | ||
mockstarPort, | ||
}); | ||
}, | ||
}); | ||
// 启动 matman | ||
const matmanAppPath = path.join(WORKSPACE_PATH, './DevOps/matman-app'); | ||
await e2eRunner.startMatman(matmanAppPath); | ||
// debug 日志 | ||
console.log({ | ||
bootstrapMockstarPort, | ||
bootstrapWhistlePort, | ||
mockstarPort, | ||
whistlePort, | ||
}); | ||
console.log(prepareSUTResult); | ||
console.log(e2eRunner); | ||
})(); |
@@ -43,3 +43,3 @@ const { expect } = require('chai'); | ||
isExist: true, | ||
wording: '我是原始信息', | ||
wording: '我是原始信息,请点击下面按钮之后可更新信息', | ||
isSuccess: false, | ||
@@ -56,3 +56,3 @@ isLoaded: false, | ||
it('消息信息为原始信息', function () { | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息'); | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息,请点击下面按钮之后可更新信息'); | ||
}); | ||
@@ -59,0 +59,0 @@ }); |
@@ -43,3 +43,3 @@ const { expect } = require('chai'); | ||
isExist: true, | ||
wording: '我是原始信息', | ||
wording: '我是原始信息,请点击下面按钮之后可更新信息', | ||
isSuccess: false, | ||
@@ -56,3 +56,3 @@ isLoaded: false, | ||
it('消息信息为原始信息', function () { | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息'); | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息,请点击下面按钮之后可更新信息'); | ||
}); | ||
@@ -59,0 +59,0 @@ }); |
@@ -43,3 +43,3 @@ const { expect } = require('chai'); | ||
isExist: true, | ||
wording: '我是原始信息', | ||
wording: '我是原始信息,请点击下面按钮之后可更新信息', | ||
isSuccess: false, | ||
@@ -56,3 +56,3 @@ isLoaded: false, | ||
it('消息信息为原始信息', function () { | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息'); | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息,请点击下面按钮之后可更新信息'); | ||
}); | ||
@@ -59,0 +59,0 @@ }); |
@@ -40,3 +40,3 @@ const { expect } = require('chai'); | ||
isExist: true, | ||
wording: '我是原始信息', | ||
wording: '我是原始信息,请点击下面按钮之后可更新信息', | ||
isSuccess: false, | ||
@@ -53,3 +53,3 @@ isLoaded: false, | ||
it('消息信息为原始信息', function () { | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息'); | ||
expect(data.msgInfo.wording).to.be.equal('我是原始信息,请点击下面按钮之后可更新信息'); | ||
}); | ||
@@ -56,0 +56,0 @@ }); |
@@ -1,51 +0,22 @@ | ||
const path = require('path'); | ||
const { E2ERunner } = require('matman-e2e-test'); | ||
const whistle = require('../DevOps/whistle'); | ||
const { createE2ERunner, prepareSUT, runE2ETestDirect } = require('./e2e.config'); | ||
(async () => { | ||
const WORKSPACE_PATH = path.join(__dirname, '../'); | ||
const OUTPUT_PATH = path.join(__dirname, '../.matman_output'); | ||
// 创建 E2ERunner | ||
const e2eRunner = await createE2ERunner(); | ||
const e2eRunner = new E2ERunner({ | ||
workspacePath: WORKSPACE_PATH, | ||
outputPath: OUTPUT_PATH, | ||
}); | ||
// 开始启动 | ||
// 设置启动 | ||
await e2eRunner.start(); | ||
// 构建项目 | ||
await e2eRunner.buildProject('npx cross-env ENABLE_E2E_TEST=1 npm run build-dev', { | ||
cwd: WORKSPACE_PATH, | ||
}); | ||
// 测试之前准备环境 | ||
const prepareSUTResult = await prepareSUT(e2eRunner, { isBuildDev: true }); | ||
const { whistlePort, matmanAppPath } = prepareSUTResult; | ||
// 启动 mockstar | ||
const mockstarAppPath = path.join(WORKSPACE_PATH, './DevOps/mockstar-app'); | ||
const mockstarPort = await e2eRunner.startMockstar(mockstarAppPath); | ||
// 启动 whistle | ||
const whistlePort = await e2eRunner.startWhistle({ | ||
getWhistleRules: () => { | ||
return whistle.getDevRules({ | ||
projectRootPath: WORKSPACE_PATH, | ||
shouldUseMockstar: true, | ||
mockstarPort, | ||
}); | ||
}, | ||
}); | ||
// 启动 matman | ||
const matmanAppPath = path.join(WORKSPACE_PATH, './DevOps/matman-app'); | ||
await e2eRunner.startMatman(matmanAppPath); | ||
// 启动 e2e test | ||
await e2eRunner.runE2ETest('tnpm run test:e2e:direct', { | ||
cwd: WORKSPACE_PATH, | ||
// 直接执行测试文件 | ||
await runE2ETestDirect(e2eRunner, { | ||
whistlePort, | ||
matmanAppPath, | ||
mochawesomeJsonFilePath: path.join(OUTPUT_PATH, './mochawesome/mochawesome.json'), | ||
}); | ||
// 结束 | ||
// 设置结束 | ||
await e2eRunner.stop(); | ||
})(); |
@@ -1,51 +0,22 @@ | ||
const path = require('path'); | ||
const { E2ERunner } = require('matman-e2e-test'); | ||
const whistle = require('../DevOps/whistle'); | ||
const { createE2ERunner, prepareSUT, runE2ETestDirect } = require('./e2e.config'); | ||
(async () => { | ||
const WORKSPACE_PATH = path.join(__dirname, '../'); | ||
const OUTPUT_PATH = path.join(__dirname, '../.matman_output'); | ||
// 创建 E2ERunner | ||
const e2eRunner = await createE2ERunner(); | ||
const e2eRunner = new E2ERunner({ | ||
workspacePath: WORKSPACE_PATH, | ||
outputPath: OUTPUT_PATH, | ||
}); | ||
// 开始启动 | ||
// 设置启动 | ||
await e2eRunner.start(); | ||
// 构建项目 | ||
await e2eRunner.buildProject('npx cross-env ENABLE_E2E_TEST=1 npm run build-prod', { | ||
cwd: WORKSPACE_PATH, | ||
}); | ||
// 测试之前准备环境 | ||
const prepareSUTResult = await prepareSUT(e2eRunner, {}); | ||
const { whistlePort, matmanAppPath } = prepareSUTResult; | ||
// 启动 mockstar | ||
const mockstarAppPath = path.join(WORKSPACE_PATH, './DevOps/mockstar-app'); | ||
const mockstarPort = await e2eRunner.startMockstar(mockstarAppPath); | ||
// 启动 whistle | ||
const whistlePort = await e2eRunner.startWhistle({ | ||
getWhistleRules: () => { | ||
return whistle.getProdRules({ | ||
projectRootPath: WORKSPACE_PATH, | ||
shouldUseMockstar: true, | ||
mockstarPort, | ||
}); | ||
}, | ||
}); | ||
// 启动 matman | ||
const matmanAppPath = path.join(WORKSPACE_PATH, './DevOps/matman-app'); | ||
await e2eRunner.startMatman(matmanAppPath); | ||
// 启动 e2e test | ||
await e2eRunner.runE2ETest('tnpm run test:e2e:direct', { | ||
cwd: WORKSPACE_PATH, | ||
// 直接执行测试文件 | ||
await runE2ETestDirect(e2eRunner, { | ||
whistlePort, | ||
matmanAppPath, | ||
mochawesomeJsonFilePath: path.join(OUTPUT_PATH, './mochawesome/mochawesome.json'), | ||
}); | ||
// 结束 | ||
// 设置结束 | ||
await e2eRunner.stop(); | ||
})(); |
@@ -22,2 +22,5 @@ const path = require('path'); | ||
template: './public/sogou.html', | ||
templateParameters: { | ||
buildVersionDesc: '构建版本:开发环境版本(webpack.dev.config.js)', | ||
}, | ||
}), | ||
@@ -24,0 +27,0 @@ ], |
@@ -22,2 +22,5 @@ const path = require('path'); | ||
template: './public/sogou.html', | ||
templateParameters: { | ||
buildVersionDesc: '构建版本:生成环境版本(webpack.prod.config.js)', | ||
}, | ||
}), | ||
@@ -24,0 +27,0 @@ ], |
Sorry, the diff of this file is not supported yet
69240
50
1134