test: use env variable variables in login.test.js

This commit is contained in:
a632079 2020-09-07 20:55:04 +08:00
parent 9aed821057
commit bc71f537ad
No known key found for this signature in database
GPG Key ID: 8A3F5C6934182137
2 changed files with 8 additions and 3 deletions

4
.github/node.js.yml vendored
View File

@ -26,6 +26,10 @@ jobs:
${{ runner.os }}-node-
- run: npm ci
name: Install dependencies
- name: Set Test Env
run: |
export NCM_API_TEST_LOGIN_PHONE=${{ secrets.NCM_API_TEST_LOGIN_PHONE }}
export NCM_API_TEST_LOGIN_PASSWORD=${{ secrets.NCM_API_TEST_LOGIN_PASSWORD }}
- name: Test
run: npm test
lint:

View File

@ -3,12 +3,13 @@ const request = require('request')
const host = global.host || 'http://localhost:3000'
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!');
const phone = ''
const password = ''
describe('测试登录是否正常', () => {
it('手机登录 code 应该等于200', done => {
const qs = {
phone: phone,
password: password
phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '',
password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || ''
}
request.get({url: `${host}/login/cellphone`, qs: qs}, (err, res, body) => {