<commit_before># test ouput directory to confirm creation of test files
$commandname = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. (Join-path (($PSScriptRoot, '.\' -ne '')[0]) "constants.ps1")  #if running in interactive console, cd to folder and you can run this without error
write-host "loaded constants"

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
    BeforeAll {
        $script:PesterOutputPath = "TestDrive:$commandName"


        $database = "dbatoolsci_frk_$(Get-Random)"
        $database2 = "dbatoolsci_frk_$(Get-Random)"
        $server = Connect-DbaInstance -SqlInstance $script:instance2
        $server.Query("CREATE DATABASE $database")
        $server.Query("CREATE DATABASE $database2")

    }
    AfterAll {
        $null = Get-DbaDatabase -SqlInstance $server -Databases @($database, $database2) | Remove-DbaDatabase -Confirm:$false
        Remove-Item $script:PesterOutputPath -recurse -erroraction silentlycontinue  #clear test folder contents

    }
    AfterEach {
        Remove-Item $script:PesterOutputPath -Recurse -erroraction silentlycontinue #clear test folder contents, doesn't need to fail if cleanup fails
    }


    Context "verifying output when running queries" {
        It "runs a specific query" {
            $results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Memory Clerk Usage'
            @($results).Count | Should -Be 1
        }
        It "works with DatabaseSpecific" {
            $results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -DatabaseSpecific -QueryName 'Database-scoped Configurations'
            @($results).count | Should -BeGreaterThan 10
        }
    }

    context "verifying output when exporting queries as files instead of running" {
<commit_msg>Pester Fix<commit_after># test ouput directory to confirm creation of test files
$commandname = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. (Join-path (($PSScriptRoot, '.\' -ne '')[0]) "constants.ps1")  #if running in interactive console, cd to folder and you can run this without error
write-host "loaded constants"

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
    BeforeAll {
        $script:PesterOutputPath = "TestDrive:$commandName"


        $database = "dbatoolsci_frk_$(Get-Random)"
        $database2 = "dbatoolsci_frk_$(Get-Random)"
        $server = Connect-DbaInstance -SqlInstance $script:instance2
        $server.Query("CREATE DATABASE $database")
        $server.Query("CREATE DATABASE $database2")

    }
    AfterAll {
        $null = Get-DbaDatabase -SqlInstance $server -Databases @($database, $database2) | Remove-DbaDatabase -Confirm:$false
        Remove-Item $script:PesterOutputPath -recurse -erroraction silentlycontinue

    }
    AfterEach {
        Remove-Item $script:PesterOutputPath -Recurse -erroraction silentlycontinue
    }


    Context "verifying output when running queries" {
        It "runs a specific query" {
            $results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Memory Clerk Usage'
            @($results).Count | Should -Be 1
        }
        It "works with DatabaseSpecific" {
            $results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -DatabaseSpecific
            @($results).count | Should -BeGreaterThan 10
        }
    }

    context "verifying output when exporting queries as files instead of running" {

{'fraction_non_alphanumeric': 0.10253552521593759, 'fraction_numerical': 0.006687099470604625, 'mean_word_length': 3.362089914945322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548672', 'n_tokens_mistral': 1035, 'n_tokens_neox': 989, 'n_words': 283}