Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spartez-software/azure-test

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spartez-software/azure-test

azure integration tests helper lib

  • 0.0.73
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
decreased by-38.52%
Maintainers
0
Weekly downloads
 
Created
Source

azure-tests (Beta)

Helper lib - azure integration tests

prerequisites

  • ability to run tests using jest

installation

npm install @spartez-software/azure-test --save-dev

setup

  • go get yourself an Azure devOps instance
  • setup .env
TEST_AZURE_URL=https://dev.azure.com/your-azure-site-name
TEST_AZURE_USER_TOKEN=pst! it is a secret pat, it belongs to the user that we use to make changes in Azure!

usage (jest/typescript example)

import { step } from '@spartez-software/test-utils';
import { TeamProjectReference } from 'azure-devops-node-api/interfaces/CoreInterfaces';
import { WorkItem } from 'azure-devops-node-api/interfaces/WorkItemTrackingInterfaces';
import { AzureDevOps } from '@spartez-software/azure-test/AzureDevOps';

describe('azure tests', () => {
    const azureDevOps = AzureDevOps.fromEnv();
    let teamProjectReference: TeamProjectReference;

    jest.retryTimes(5);
    jest.setTimeout(240000);

    beforeEach(async () => {
        await step('Create azure Project', async () => {
            teamProjectReference = await azureDevOps.createProject();
            expect(teamProjectReference).toBeDefined();
        });
    });

    it('should create and destroy project', async () => {
        const projectId = String(teamProjectReference.id);
        const workItemTrackingApi = await azureDevOps.connection.getWorkItemTrackingApi();
        const json = [{
            op: 'add',
            path: '/fields/System.Title',
            from: null,
            value: 'Sample task',
        }];

        let wi: WorkItem;
        await step('Create work item', async () => {
            wi = await workItemTrackingApi.createWorkItem({}, json, projectId, 'Task');
            expect(wi).toBeDefined();
        });

        await step('Verify workitem exists', async () => {
            const workItem = await workItemTrackingApi.getWorkItem(wi.id as number);
            expect(workItem).toBeDefined();
        });
    });

    afterEach(async () => {
        await step('Delete azure project', async () => {
            if (teamProjectReference.id) {
                await azureDevOps.deleteProject(teamProjectReference.id);
            }
        });
    });
});

pitfalls

  • Azure DevOps can take a long time to create a project, set up timeouts accordingly.
  • Large number of project, even deleted ones, make the create project time even longer.

FAQs

Package last updated on 05 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc