mirror of
https://github.com/web-infra-dev/midscene.git
synced 2025-11-22 04:58:29 +00:00
* feat: enable search area for locate * fix: update evaluation * fix: build error * fix: ci * fix: locator * feat: show searchArea in report * chore: add yaml support for aiTap * feat: update status tip * fix: #473 (#484) * chore: optimize unit test list --------- Co-authored-by: zhouxiao.shaw <zhouxiao.shaw@bytedance.com>
40 lines
1001 B
TypeScript
40 lines
1001 B
TypeScript
import { buildYaml, parseYamlScript } from '@/yaml';
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
describe('utils', () => {
|
|
test('build yaml', () => {
|
|
const yaml = buildYaml({ url: 'https://www.baidu.com' }, []);
|
|
expect(yaml).toMatchSnapshot();
|
|
});
|
|
|
|
describe('parseYamlScript', () => {
|
|
test('interpolates environment variables', () => {
|
|
process.env.TEST_URL = 'https://example.com';
|
|
process.env.TEST_PATH = '/test/path';
|
|
|
|
const yamlContent = `
|
|
target:
|
|
url: "\${TEST_URL}\${TEST_PATH}"
|
|
tasks:
|
|
- sleep: 1000
|
|
`;
|
|
|
|
const result = parseYamlScript(yamlContent);
|
|
expect(result.target.url).toBe('https://example.com/test/path');
|
|
});
|
|
|
|
test('throws error for undefined environment variables', () => {
|
|
const yamlContent = `
|
|
target:
|
|
url: "\${UNDEFINED_ENV_VAR}"
|
|
tasks:
|
|
- sleep: 1000
|
|
`;
|
|
|
|
expect(() => parseYamlScript(yamlContent)).toThrow(
|
|
'Environment variable "UNDEFINED_ENV_VAR" is not defined',
|
|
);
|
|
});
|
|
});
|
|
});
|