简单的jest测试只是为了检查react组件是否可以呈现并且因为我导入而失败
import { Meteor } from 'meteor/meteor'
完整的错误是......
PASS imports/__partials/Navigation/__tests__/Navigation.jest.js
PASS imports/__layouts/AuthLayout/__tests__/AuthLayout.jest.js
FAIL imports/features/oAuth/ui/LoginLayout/__tests__/LoginLayout.jest.js
? Test suite failed to run
Cannot find module 'meteor/meteor' from 'index.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:142:17)
at Object.<anonymous> (imports/features/oAuth/ui/LoginLayout/index.js:2:41)
at Object.<anonymous> (imports/features/oAuth/ui/LoginLayout/__tests__/LoginLayout.jest.js:4:40)
PASS imports/staticTests/quickCheckboxTest/__tests__/CheckboxWithLabel.jest.js
PASS imports/staticTests/quickLinkTest/__tests__/Link.react.jest.js
Run Code Online (Sandbox Code Playgroud)
我将假设它,因为流星不构建,因此meteor/meteor不存在,任何帮助使这个工作将不胜感激.:)
我的假设是正确的,这基本上是因为meteor没有构建npm模块.
我正在尝试公开我的api所以我可以向它发送请求.但是,当我使用命令时,minikube service api --url我什么都没得到.我所有的豆荚都运行得很好,kubectl get pods所以我坚持认为这可能是什么.
api-1007925651-0rt1n 1/1 Running 0 26m
auth-1671920045-0f85w 1/1 Running 0 26m
blankit-app 1/1 Running 5 5d
logging-2525807854-2gfwz 1/1 Running 0 26m
mongo-1361605738-0fdq4 1/1 Running 0 26m
jwl:.build jakewlace$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
api 10.0.0.194 <none> 3001/TCP 23m
auth 10.0.0.36 <none> 3100/TCP 23m
kubernetes 10.0.0.1 <none> 443/TCP 5d
logging 10.0.0.118 <none> 3200/TCP 23m
mongo 10.0.0.132 <none> 27017/TCP 23m
jwl:.build jakewlace$
jwl:.build jakewlace$ minikube service api --url
jwl:.build jakewlace$ …Run Code Online (Sandbox Code Playgroud) 我完全知道如何在Drupal 7中这样做,所以我将解释我通常使用Drupal 7做什么.
在制作自定义模块时,我经常使用hook_theme,它非常强大且可重复使用!
/**
* Implements hook_theme().
*/
function MODULE_theme() {
$themes = array();
$themes['name_of_theme'] = array(
'path' => drupal_get_path('module', 'module') .'/templates',
'template' => 'NAME_OF_TEPLATE',
'variables' => array(
'param1' => NULL,
'param2' => NULL,
),
);
return $themes;
}
Run Code Online (Sandbox Code Playgroud)
然后我会使用这个主题
theme('name_of_theme', array(
'param1' => 'VALUEA',
'param2' => 'VALUEB'
));
Run Code Online (Sandbox Code Playgroud)
这将返回html,我会很高兴.
所以Drupal 8需要掌握它.
/**
* Implements hook_theme().
*/
function helloworld_theme() {
$theme = [];
$theme['helloworld'] = [
'variables' => [
'param_1' => [],
'param_2' => 'hello',
]
];
return $theme; …Run Code Online (Sandbox Code Playgroud) 我有一个查询,它给我一个笔记列表和一个订阅,它通过改变查询来监听和插入新笔记.但问题是第一个注释没有添加.
所以让我添加更多细节,最初是一个包含一个名为notes的属性的对象的查询响应,如果我们尝试添加一个注释,该属性将被删除.注释是创建的,所以如果我刷新我的应用程序,查询将返回注释然后如果我尝试再次添加注释,注释将添加到查询对象中的数组.
这是我的笔记容器,我查询笔记并创建一个新属性来订阅更多笔记.
export const NotesDataContainer = component => graphql(NotesQuery,{
name: 'notes',
props: props => {
console.log(props); // props.notes.notes is undefined on first note added when none exists.
return {
...props,
subscribeToNewNotes: () => {
return props.notes.subscribeToMore({
document: NotesAddedSubscription,
updateQuery: (prevRes, { subscriptionData }) => {
if (!subscriptionData.data.noteAdded) return prevRes;
return update(prevRes, {
notes: { $unshift: [subscriptionData.data.noteAdded] }
});
},
})
}
}
}
})(component);
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒,谢谢.
编辑:
export const NotesQuery = gql`
query NotesQuery {
notes {
_id
title
desc …Run Code Online (Sandbox Code Playgroud) apollo ×1
docker ×1
drupal ×1
drupal-8 ×1
ecmascript-6 ×1
graphql ×1
javascript ×1
jestjs ×1
kubernetes ×1
meteor ×1
minikube ×1
php ×1
reactjs ×1
testing ×1