我目前使用Cypress作为我的测试工具,并且在gitlab ci上运行时遇到了一些小问题。赛普拉斯利用Gitlab变量
的问题
部分我赛普拉斯测试目前使用敏感的信用卡信息,所以当我上传到gitlab库我必须试着找出办法让任何人观看视频的说:“敏感信息”。最终,我试图利用Gitlabs方便的“秘密变量”功能。
设置完所有我需要隐藏的变量后,我进入我的gitlab-ci.yml文件并进行设置,以便.gitlab-ci.yml文件创建一个名为“cypress /支持/ PaymentCredentials.js”,并认为文件中的所有的敏感付款信息将被存储为JavaScript的变量(如下图所示)
image: bahmutov/cypress-image
# caching node_modules folder
# https://about.gitlab.com/2016/03/01/gitlab-runner-with-docker/
cache:
paths:
- node_modules/
before_script:
- cypress verify
- "echo -e \"export default {CARDHOLDER_NAME: '$CARDHOLDER_NAME', CARD_CC: '$CARD_CC', CARD_CC_MONTH: '$CARD_CC_MONTH', CARD_CC_YEAR: '$CARD_CC_YEAR', CARD_CC_CCV: '$CARD_CC_CCV'}\" > cypress/support/PaymentCredentials.js"
stages:
- build
- test
build-specs:
stage: build
script:
- npm install
artifacts:
paths:
- cypress/integration
.job_template: &e2e_test_definition
script:
- echo $CARDHOLDER_NAME
- export $CARDHOLDER_NAME
- cypress ci --spec "cypress/integration/$CI_BUILD_NAME.js"
Test_Project:
<<: *e2e_test_definition
所以在赛普拉斯我设置了集成文件像这样:
describe('Test', function(){
afterEach(function(){
})
beforeEach(function(){
})
//The entire job
context('Test - Full Functionality Test', function(){
it('Front-end Walkthrough', function(){
/*This is going to go through the first step on Test*/
stepOne()
/*This is going to go through the Second step on Test*/
stepTwo()
/*This is going to go through the Third step on Test*/
stepThree()
/*Page loads very slowly, needed some buffer*/
cy.wait(5000)
/*This is going to go through the Fourth step on Test*/
cy.then(function(){
cy
.get('[name=method]').select("CC") //select CC
.get('#name').type(CARDHOLDER_NAME)
.get('#number').type(CARD_CC)
.get('#month').select(CARD_CC_MONTH)
.get('#year').select(CARD_CC_YEAR)
.get('#ccv').type(CARD_CC_CCV)
.get('[type=checkbox]').check({force: true})
.get('#scoreboard-enroll-form').submit()
})
})
})
})
当我运行管道时,我仍然收到一个错误的sta婷认为,“CARDHOLDER_NAME”尚未定义: Gitlab ci build report
是否有承担这种情况下任何建议的方法?我有没有可笑的错误?
无论哪种方式,我感谢任何帮助!