我正在构建一个Django应用程序,它提供单页Angular应用程序.
Django发布了Angular的index.html,其中包含以下usemin脚本块:
<!-- build:js scripts/scripts.js -->
<script src="{% static "scripts/app.js" %}"></script>
<script src="{% static "scripts/controllers/main.js" %}"></script>
<script src="{% static "scripts/controllers/stats.js" %}"></script>
<script src="{% static "scripts/directives/highchart.js" %}"></script>
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
Usemin试图在文件系统上找到"{%static"scripts/app.js"%}",当然失败了,因为它应该真正想要找到的是"scripts/app.js".
有没有人见过这个解决方法?
我正在使用React 测试库来测试一个组件,该组件通过 redux thunk 获取 componentDidMount 中的数据,并使用 MSW JS 模拟后端。
我的测试本质上是:
const history = createMemoryHistory()
history.push(`/${DECK_ID}`)
const { getByText } = render(
<Provider store={store}>
<Router basename="/games" history={history}>
<App />
</Router>
</Provider>
)
await waitFor(() => getByText('Create Card'))
fireEvent.click(getByText('Create Card'))
await waitFor(() => getByText(`Id: ${NEW_CARD_TYPE_ID}`))
Run Code Online (Sandbox Code Playgroud)
奇怪的是,没有找到“创建卡片”:
TestingLibraryElementError: Unable to find an element with the text: Create Card...
...
124 | await waitFor(() => getByText('Create Card')) …Run Code Online (Sandbox Code Playgroud) async-await reactjs react-router react-redux react-testing-library
angularjs ×1
async-await ×1
django ×1
grunt-usemin ×1
gruntjs ×1
react-redux ×1
react-router ×1
reactjs ×1