我正在试图弄清楚如何让Jest在我的环境中工作,而我遇到的问题是这个项目在node_modules的子目录中有一堆自定义组件.
我收到这个错误:
FAIL src/mantle/tools/searchindexer/apps/DataMover/js/components/__test__/GenericJobsTable.test.jsx
? Test suite failed to run
/Users/rob/repos/mesa/ui/node_modules/iggy-common/components/IggyTable.jsx:1
({"Object.":function(module,exports,require,__dirname,__filename,global,jest){import React, {PropTypes} from "react";
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object. (src/mantle/tools/searchindexer/apps/DataMover/js/components/JobsTable/GenericJobsTable.jsx:7:18)
at Object. (src/mantle/tools/searchindexer/apps/DataMover/js/components/__test__/GenericJobsTable.test.jsx:5:25)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.4s
Ran all test suites matching "GenericJobsTable".
Run Code Online (Sandbox Code Playgroud)
我运行jest ^20.0.3
,并babel-jest ^20.0.3
在7.7.1的NodeJS.
在我的package.json中,这是我拥有的jest配置部分:
"jest": {
"verbose": true,
"transform": {
"^.+\\.jsx$": "babel-jest"
},
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
我将我的根.babelrc
定义为: …
任何人都可以提供有关如何返回数组项子集的建议吗?例如,假设我有一个文档集合(类似于下面的示例),其中包含一个简单的 _id 键和一个包含对象数组的键。
我想找到所有 _id 和符合简单条件的匹配对象:
// campaigns
{
"_id" : "Fred's C25K",
"campaignData" : [
{
"date" : "2015-06-17",
"source" : "nike"
},
{
"date" : "2015-06-17",
"source" : "reebok",
},
{
"date" : "2015-06-12",
"source" : "nike"
},
{
"date" : "2015-06-14",
"source" : "adidas"
},
]
},
{
"_id" : "Mike's Marathon",
"campaignData" : [
{
"date" : "2015-06-17",
"source" : "nike"
}
]
},
{
"_id" : "Jacob's Jamboree",
"campaignData" : [
{
"date" : "2015-06-17", …
Run Code Online (Sandbox Code Playgroud) 知道为什么我可以让我的AVPlayerViewController类播放内容,但无法让它显示播放控件吗?播放器按预期加载内容,但就是这样.
在我的MediaPlayerViewController.m类中,我有:
#pragma mark - Player
- (void)setupPlayer{
// Sample URLs to use either a local file or streaming URL
NSURL *url = [[NSBundle mainBundle] URLForResource:@"Besan" withExtension:@"mp4"];
//url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=qcI2_v7Vj2U"];
// Create an instance of the AVPlayer object
self.player = [AVPlayer playerWithURL:url];
// Keep an eye on the status of our player
[self.player addObserver:self forKeyPath:@"status" options:0 context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if (object == self.player && [keyPath isEqualToString:@"status"]) {
if (self.player.status == AVPlayerStatusFailed){
NSLog(@"AVPlayer …
Run Code Online (Sandbox Code Playgroud)