import { expect } from '@wdio/globals'
import { Task } from '@serenity-js/core'
describe.skip('Source maps support for ESM projects', () => {
it('should detect line number correctly', async () => {
const [message, ...frames] = fn1()
expect(message).toEqual('Error: Caller location marker')
const locations = frames.map(frame => frame.match(/.*\/(.*?\d+:\d+)/)[1]).slice(0, 4)
expect(locations).toEqual([
'source-maps.e2e.ts:44:19',
'source-maps.e2e.ts:40:12',
'source-maps.e2e.ts:36:12',
'source-maps.e2e.ts:9:38',
])
})
it('should detect instantiation location of a Serenity/JS interaction', async () => {
const location = serenityTask()
.instantiationLocation()
expect(location.line).toEqual(26)
expect(location.column).toEqual(26)
})
})
function fn1() {
return fn2()
}
function fn2() {
return readStack()
}
function readStack() {
const error = new Error('Caller location marker')
return (error.stack || '').split('\n')
}
const serenityTask = () =>
Task.where('#actor tries to reproduce a bug')