* * * @param {string} testsPath * @param {string} targetFolderPath * @param {Object } pathsToType * @param {Object } pathsToValue * * @returns {Array }
(testsPath, targetFolderPath, pathsToType, pathsToValue)
| 226 | * @returns {Array<string>} |
| 227 | */ |
| 228 | function getImportString(testsPath, targetFolderPath, pathsToType, pathsToValue) { |
| 229 | const importStrings = [] |
| 230 | |
| 231 | for (const name in pathsToType) { |
| 232 | const originalPath = pathsToType[name] |
| 233 | const relativePath = getPath(originalPath, targetFolderPath, testsPath) |
| 234 | // 4.x is ESM-first: step files and page objects use `export default`, |
| 235 | // so the type is reached via `.default` regardless of file extension |
| 236 | // (.js, .ts, or no extension, as set in `include`). |
| 237 | importStrings.push(`type ${name} = typeof import('${relativePath}').default;`) |
| 238 | } |
| 239 | |
| 240 | for (const name in pathsToValue) { |
| 241 | const originalPath = pathsToValue[name] |
| 242 | const relativePath = getPath(originalPath, targetFolderPath, testsPath) |
| 243 | if (originalPath.endsWith('.js') || originalPath.endsWith('.ts')) { |
| 244 | importStrings.push(`type ${name} = InstanceType<typeof import('${relativePath}').default>;`) |
| 245 | } else { |
| 246 | importStrings.push(`type ${name} = import('${relativePath}');`) |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return importStrings |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * @param {Map} map |
no test coverage detected