🔏
Azure Serverless Quickstart
  • Introduction
  • Initial Setup
    • Workstation Installs
    • Codebase
      • Directory Structure
      • User Interface Project
        • Configuring StoryBook
        • Configure Tailwind
        • Configure Craco
        • -Architectural Decision Log
      • Data Access Project
        • DDD
      • Untitled
      • Full Stack Debugging
      • Creating GitHub Project
    • Infrastructure
      • Configure Session Behavior
      • Create AAD Tenant
      • Resource Group
      • Create AAD B2C Instance
        • Identity Experience Framework
        • Configure Session Behavior
      • Storage Account & CDN
        • CDN Rules
        • Configure Azure BLOB Storage
      • App Insights
        • Create AppInsight Account
        • Apollo GraphQL App Insights Configuration
      • CosmosDB
      • Twilio SendGrid
      • KeyVault
      • Function
      • Function App Settings
      • Front Door
      • DevOps
      • Optional Items
        • Azure Data Factory
      • Azure Event Hub
    • CICD and Source Control
      • Azure DevOps
      • SonarCloud
        • Incorporate into Yaml
      • Chromatic
      • User Interface YAML
      • CICD for Data Access
        • Create Pipeline
        • Data Access YAML
  • Application Structure
    • Connect Apollo
      • Apollo Overview
      • Create Apollo Component
    • MongoDB Integration
      • Mappings
      • Directory Structure
      • Apollo Connection
      • Models
      • Queries Mutations and Subscriptions
      • Caching Reponses
    • Integrating GraphQL Tools
      • GraphQL Code Generator
    • Feature Flags
      • Flag Structure & Storage
      • Website Integration
      • Apollo Integration
      • Tips and Techniques
      • Alternative Approaches
    • React Router
    • Adding Authentication
      • Create AAD Applications
      • Configure AAD For External Identities
      • Adding MSAL And React
      • Add MSAL to the build
      • Add MSAL to ApolloClient
      • Add MSAL to ApolloServer
    • Ant Design
    • Jest Tests
  • Azure Active Directory Business-to-Consumer (AD B2C)
    • Introduction
    • How to navigate through AD B2C documentation
    • Localization
    • Abbreviations
    • Azure AD B2C Extension
  • Cognitive Search
  • Cost Analysis
  • Technical Architecture
    • Identity and Access Control
  • Adding Functionality
    • Google Analytics
      • Create Analytics
    • DAPR
      • DAPR setup
      • DAPR Services (ignore for now)
        • Identity
  • Patterns and Practices
    • Idempotent Messages
    • Pathways
    • DDD
      • Initial Setup
        • Aggregate Root
        • Entity
        • Value Object
      • Field Types
        • Primitive Types
        • Non-Primitive Types
          • Types.DocumentArray
          • PopulatedDoc
          • Custom Types
      • Example Walkthrough
  • Open Items
    • Issue Tracking
  • Helpful Resources
  • DDD
    • Page 1
  • Experimental
    • StaticWebApp
    • Azure Maps
Powered by GitBook
On this page

Was this helpful?

  1. Application Structure

Jest Tests

Data Access Project

Data Access Project

Initialize Jest by running these commands

terminal : azure-quickstart/data-access
npm i -D jest typescript
npm i -D ts-jest @types/jest
npx ts-jest config:init

Confgure jest config

azure-quickstart/data-access/jest.config.js
module.exports = {
  roots: ["<rootDir>/."],
  preset: 'ts-jest',
  testEnvironment: 'node',
  testMatch: ['**/**/*.test.ts'],
    coverageReporters: ['json', 'lcov'],
    coverageDirectory: 'coverage',
    collectCoverageFrom: [
      "**/*.{js,jsx,ts}",
      "!**/node_modules/**",
      "!**/dist/**"
    ]
};

Configure package.json

azure-quickstart/data-access/package.json
...
  "scripts": {
    "test:ci": "npx jest --watchAll=false --coverage=true",
    "test": "npx jest --watch"
  },

...

Configure yaml

azure-quickstart/data-access/azure-pipelines.yml
>> UPDATE NPM BUILD TASK
>> Add 'npm run test:ci' before build production
...
    # Build project and run tests
    - task: Bash@3
      displayName: 'NPM: Prepare binaries and run tests'
      inputs:
        targetType: 'inline'
        script: |
          export NODE_OPTIONS=--max_old_space_size=16384
          npm ci
          npm run test:ci
          npm run build:production
        workingDirectory: 'data-access'
...

>> UPDATE SONAR CLOUD PREPARE TASK
>> Add sonar.javascript.lcov.reportPaths to extraProperties
...
    # Set up SonarCloud
    - task: SonarCloudPrepare@1
      displayName: 'SonarCloud: Prepare analysis configuration'
      inputs:
        SonarCloud: 'sonarcloud'
        organization: 'simnova'
        scannerMode: 'CLI'
        configMode: 'manual'
        cliProjectKey: 'sharethrift-data-access'
        cliProjectName: 'sharethrift-data-access'
        cliSources: './data-access'
        extraProperties: |
          sonar.javascript.lcov.reportPaths=$(System.DefaultWorkingDirectory)/data-access/coverage/lcov.info

Configure .gitignore

.gitignore
...
...
/coverage

References:

PreviousAnt DesignNextAzure Active Directory Business-to-Consumer (AD B2C)

Last updated 3 years ago

Was this helpful?