import assert from 'node:assert'
import { resolve } from 'node:path'
import { env } from 'node:process'
import {
  compressArtifact,
  joinUrl,
  setup,
  teardown,
} from '../../_testHelpers/index.js'

// "Could not find 'Docker', skipping 'Docker' tests."
const _describe = env.DOCKER_DETECTED ? describe : describe.skip

_describe('Artifact with docker tests', function desc() {
  this.timeout(120000)

  beforeEach(async () => {
    await compressArtifact(__dirname, './artifacts/hello.zip', ['./handler.js'])
    return setup({
      servicePath: resolve(__dirname),
    })
  })

  afterEach(() => teardown())

  //
  ;[
    {
      description: 'should work with artifact in docker container',
      expected: {
        message: 'Hello Node.js!',
      },
      path: '/dev/hello',
    },
  ].forEach(({ description, expected, path }) => {
    it(description, async () => {
      const url = joinUrl(env.TEST_BASE_URL, path)
      const response = await fetch(url)
      const json = await response.json()

      assert.deepEqual(json, expected)
    })
  })
})

@@ -34,16 +34,25 @@
 import %7B
+ dirname,
  resolve
@@ -106,16 +106,57 @@
 rocess'%0A
+import %7B fileURLToPath %7D from 'node:url'%0A
 import %7B
@@ -250,130 +250,67 @@
 s'%0A%0A
-// %22Could not find 'Docker', skipping 'Docker' tests.%22%0Aconst _describe = env.DOCKER_DETECTED ? describe : describe.skip
+const __dirname = dirname(fileURLToPath(import.meta.url))
 %0A%0A
-_
 desc
@@ -848,31 +848,154 @@
 tion, async 
-() =%3E %7B
+function it() %7B%0A      // %22Could not find 'Docker', skipping tests.%22%0A      if (!env.DOCKER_DETECTED) %7B%0A        this.skip()%0A      %7D%0A
 %0A      const

fix docker artifact tests (#1487)