dimanche 28 juin 2020

Testcafe in azure devops with specific URL

I am trying to e2e-testcafe in my azure devops uisng IAAC(Infra as a code) for java-script code. So i have different stages build, test and deploy to different environments. After deploying to test environment (Storage account) I need to e2e in that deployed code. So i am using below steps for that jobs: my azure-pipeline.yml has below

- job: e2e_tests
  pool:
    vmImage: 'Ubuntu 16.04'
  steps:
  - task: NodeTool@0
    inputs:
      # Replace '10.14' with the latest Node.js LTS version
      versionSpec: '10.14'
    displayName: 'Install Node.js'
  - script: npm install
    displayName: 'Install TestCafe'
  - script: npm test
    displayName: 'Run TestCafe Tests'
  - task: PublishTestResults@2
    inputs:
      testResultsFiles: '**/report.xml'
      testResultsFormat: 'JUnit'
---------------------------------------------------
my test.js: 

import { Selector } from 'testcafe';
const articleHeader = Selector('#article-header');
const header = Selector('h1');
fixture `Getting Started`
    .page `localhost:8080`
          
test('My first test', async t => {
    await t
        .expect(header.innerText).eql('Welcome to Your new App');
});

But here its running the tests from my test.js which is part of application and all the tests are running in localserver of the agent which is being used by azure devops for me here its windows server. But now i want to pass the URI to npm test and while it goes to my application its again picking up localhost:8080 and executing in local. So can some one help me running e2e test in the url which i pass which indeed will be the url of storageaccount? like my command should be in azurepipelines.yaml

npm run test --URL

and in my test.js it should pick up above URL i passed in Yaml while running in the pipeline.

Aucun commentaire:

Enregistrer un commentaire