我有一个docker-compose.yml文件:
version: '1'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
ports:
- '3307:3306'
volumes:
- ./db:/bitnami/mariadb
environment:
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
wordpress:
image: 'docker.io/bitnami/wordpress:5-debian-10'
ports:
- '8081:8080'
- '8444:8443'
volumes:
- ./wp:/bitnami/wordpress
depends_on:
- mariadb
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
Run Code Online (Sandbox Code Playgroud)
在 Mac(Intel)和 Linux 中,我运行docker-compose up并且运行良好。
但是在Macbook M1中,我为Apple Silicon芯片安装了Docker并更新了rosetta,最后提示如下:
wordpress_1 | wordpress 15:48:36.49 INFO ==> ** Starting Apache **
wordpress_1 | [Tue Jul 13 15:48:36.652803 2021] [core:emerg] [pid 1] (95)Operation not supported: …Run Code Online (Sandbox Code Playgroud) 我的组件中有多个按钮,所有这些按钮都应该被禁用。
const buttons = screen.getAllByRole('button');
expect(ALL BUTTONS).toHaveAttribute('disabled'); // I want something like this.
Run Code Online (Sandbox Code Playgroud)
我们怎样才能以最方便的方式写这个呢?
javascript reactjs jestjs react-testing-library testing-library
当我使用类组件时,我有代码:
setTimeout(() => console.log(this.state.count), 5000);
Run Code Online (Sandbox Code Playgroud)
当我使用钩子时:
const [count, setCount] = useState(0);
setTimeout(() => console.log(count), 5000);
Run Code Online (Sandbox Code Playgroud)
如果我触发setTimeout然后count在超时 ( 5000ms)之前将更改为 1 ,类组件将console.log(1)(最新值),并且useState是console.log(0)(注册超时时的值)。
为什么会发生这种情况?
有时我使用 withRouter 来包装我的组件并使用history, locationfrom props,有时我使用useHistory(), useLocation()。不知道这两种使用方式的优缺点。
我有这样的 JSX 代码:
<div id="parent" onClick={clickOnParent} style={{ width: 100, height: 100 }}>
<div id="child" onClick={clickOnChild} style={{ width: 20, height: 20 }} />
</div>
Run Code Online (Sandbox Code Playgroud)
当我单击parent(在 之外child)时,它将运行clickOnParent,当我单击 时,它当然child会运行。现在我只想在精确单击 时触发并忽略。我能怎么做?clickOnParentclickOnChildclickOnChildclickOnParentchild
我搜索过的所有内容总是没有/忽略顺序。
我想比较两个数组的顺序。
expect([1, 2, 3].concat(4)).toEqualWithOrder([1, 2, 3, 4])
expect([{ value: 1}, { value: 2}, { value: 3 }].concat({ value: 4 })
.toEqualWithOrder([
{ value: 1 },
{ value: 2 },
{ value: 3 },
{ value: 4 },
])
Run Code Online (Sandbox Code Playgroud)
我怎样才能用 Jest 做到这一点?我们应该使用吗JSON.stringify?
javascript ×4
reactjs ×4
jestjs ×2
css ×1
docker ×1
dom ×1
html ×1
react-hooks ×1
wordpress ×1