我有一个create react app 3项目,
所以我的src文件夹中有一些js脚本,例如:
import { Foo } from 'components/layout/Foo
不幸的是,默认情况下,testcafe编译器会抱怨它。 我读到,也许解决方案是创建一个自定义tsconfig.json,在其中声明
{
"compilerOptions": {
"baseUrl: "src"
}
}
但显然不起作用。 谢谢。
答案 0 :(得分:0)
抱歉,实际上它不是组件文件,而是src目录中的一个实用程序。
我的foo_test.js中有
import { ROOT_PATH } from '../src/utils/config'
fixture("00 Home | Arriving to the Home").page(ROOT_PATH)
test('Default | leads to the home page', async t => {
const location = await t.eval(() => window.location)
await t.expect(location.pathname).eql('/home')
})
utils / config在哪里
import { getMobileOperatingSystem } from 'utils/mobile'
export const MOBILE_OS = getMobileOperatingSystem()
let CALC_ROOT_PATH
if (MOBILE_OS === 'ios') {
document.body.className += ' cordova-ios'
CALC_ROOT_PATH = window.location.href.match(/file:\/\/(.*)\/www/)[0]
}
export const ROOT_PATH = CALC_ROOT_PATH || 'http://localhost:3000/'