我有一个模拟如下
jest.mock('react-hook-inview', () => {
const setRef = jest.fn();
const observer = jest.fn();
const intersecting = true;
const entry = {
y: 0,
};
return [setRef, intersecting, entry, observer];
});
Run Code Online (Sandbox Code Playgroud)
在这里,我想更改该intersecting
值。如何将其从一项测试更改为另一项测试?我试图使用类似工厂的东西:
const inView = (intersecting) => {
jest.mock('react-hook-inview', () => {
const setRef = jest.fn();
const observer = jest.fn();
const entry = {
y: 0,
};
return [setRef, intersecting, entry, observer];
});
}
Run Code Online (Sandbox Code Playgroud)
并像使用它一样
it('is invisible by default', () => {
const text = 'Test';
const { container …
Run Code Online (Sandbox Code Playgroud) 我有一个组件,当animated
prop 设置为 true时会“震动” 。这是它的样子
const Shake = ({ animate, children, ...props }) => {
const { x } = useSpring({
from: { x: 0 },
x: animate ? 1 : 0,
config: { mass: 12, tension: 500, friction: 80 },
});
return (
<animated.div
style={{
transformOrigin: 'center center',
transform: animate && x
.interpolate({
range: [0, 0.5, 1],
output: [0, 2, 0],
})
.interpolate((x) => `rotate(${x}deg)`),
}}
{...props}
>
{children}
</animated.div>
);
};
Run Code Online (Sandbox Code Playgroud)
我之前测试过的动画或多或少只是从一种状态转换到另一种状态,比如从 0 到 1 的不透明度。用 react-testing-library …
我正在尝试在 Docker 中运行 Nuxt.js 应用程序。我已经像这样设置了我的 Dockerfile:
FROM node:10.15.1 as base
WORKDIR /usr/src/app
COPY package.json ./
ENV HOST 0.0.0.0
FROM base as development
RUN npm install
COPY . .
ENV NODE_ENV development
EXPOSE 3000
CMD [ "npm", "run", "dev" ]
Run Code Online (Sandbox Code Playgroud)
还有我的 docker-compose.yml:
version: "3.7"
services:
frontend:
container_name: frontend
restart: unless-stopped
build:
context: .
target: development
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
ports:
- "3000:3000"
Run Code Online (Sandbox Code Playgroud)
当我跑步时,docker-compose up
我得到
frontend | These dependencies were not found: friendly-errors 10:52:33
frontend | friendly-errors 10:52:33
frontend …
Run Code Online (Sandbox Code Playgroud) 我有一个主存储库,其中包含一个 NPM 包,该包加载另一个私有 NPM 包,这两个包位于 Gitlab 中的同一组织中。
我已经研究了几个小时,发现很多方法都行不通。首先是 Dockerfile,我认为它包含添加 SSH 密钥的最常见方法。
FROM node:10.15.1-alpine as image
WORKDIR /usr/src/app
RUN apk add --update --no-cache openssh git
COPY package.json ./
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/ && \
echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa && \
touch /root/.ssh/known_hosts && \
ssh-keyscan gitlab.com > /root/.ssh/known_hosts
RUN npm install
FROM image as build
COPY . .
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait
CMD /wait && npm run start
EXPOSE 4000
Run Code Online (Sandbox Code Playgroud)
我通过以下方式调用它docker …
docker ×2
jestjs ×2
node.js ×2
reactjs ×2
gitlab ×1
javascript ×1
nuxt.js ×1
react-spring ×1
ssh ×1