@spartez-software/jira-test

jira integration tests helper lib

Usage no npm install needed!

<script type="module">
  import spartezSoftwareJiraTest from 'https://cdn.skypack.dev/@spartez-software/jira-test';
</script>

README

jira-test (Beta)

helper lib - integration tests

prerequisites

  • ability to run tests using jest

installation

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

setup

  • go get yourself a jira cloud instance
  • setup .env
TEST_JIRA_URL=https://your-cloud-jira-test-name.atlassian.net
TEST_JIRA_USER=user-that-will-make-changes-in-jira@spartez-software.com
TEST_JIRA_USER_TOKEN=pst! it is a secret, an api token!

usage (jest/typescript example)

import { step, TestLogger } from '@spartez-software/test-utils';
import { Jira, ProjectTemplateKeys } from '@spartez-software/jira-test';

describe('jira tests', () => {
    jest.retryTimes(1);
    jest.setTimeout(240000);

    const jira = Jira.getJiraFromEnv();
    const logger = new TestLogger();

    let project: string;

    it('Should create and destroy project with 2 issues', async () => {
        await step('Create jira Project', async () => {
            project = await jira.createProject();
            expect(project).toBeDefined();
        });

        logger.log(project);

        await step('adding jira issue', async () => {
            const issues = [{ summary: 'ala', type: 'Bug' }, { summary: 'pola', type: 'Bug' }];
            await jira.createSimpleIssues(project, issues);
        });
    });

    afterEach(async () => {
        await step('Delete jira project', async () => {
            if (project) {
                await jira.deleteProject(project);
            }
        });
    });

    it('Should create and destroy servicedesk project', async () => {
        await step('Create jira Project', async () => {
            project = await jira.createProjectFromTemplate(ProjectTemplateKeys.serviceDesk.simplifiedGeneralServiceDesk);
            expect(project).toBeDefined();
        });
        logger.log(project);

        await step('adding jira issue', async () => {
            const issues = [{ summary: 'ala', type: 'Task' }, { summary: 'pola', type: 'Task' }];
            await jira.createSimpleIssues(project, issues);
        });
    });

    afterEach(async () => {
        await step('Delete jira project', async () => {
            if (project) {
                await jira.deleteProject(project);
            }
        });
    });
});