使用redux-promise-middleware和web组件测试器

时间:2017-11-02 15:09:30

标签: javascript polymer web-component-tester

我有一个名为 SELECT count( *) TestCount ,count(case when result_status = 'Not A Finding' then 1 end) TestPassedCount ,ROUND((count(case when result_status = 'Not A Finding' then 1 end) / count(*))*100,2) ThePercentage ,asset FROM Table_Name group by asset 的导入

redux-scripts

我在<link rel="import" href="../config.html"> <script src="../../node_modules/redux/dist/redux.min.js"></script> <script src="../../bower_components/amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js"></script> <script src="../../bower_components/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/redux-promise-middleware/4.4.1/redux-promise-middleware.min.js"></script> <script src="./redux-promises.js"></script>

的顶部导入
redux-mixin.html

像Chrome和firefox中的魅力一样运行,但涉及到网络组件测试器:

<link rel="import" href="../../bower_components/polymer-redux/polymer-redux.html">
<script src="../../bower_components/aws-sdk/dist/aws-sdk.min.js"></script>
<link rel="import" href="redux-scripts.html">

<script type="module" src="./index.js"></script>
<script nomodule src="./bundle.js"></script>

指的是

 
redux-store.js:22 Uncaught ReferenceError: ReduxPromiseMiddleware is not defined
at redux-store.js:22

我通过将其添加到redux-store.js

的顶部实现了部分解决方法
import programs from './programs/programsReducer.js';
import videos from './videos/videosReducer.js';
import video from './video/videoReducer.js';

const rootReducer = Redux.combineReducers({
  programs,
  videos,
  video,
});

// Setup a Redux store
const initialState = {
  viewSpecificToolbar: 'videos',
};

const store = Redux.createStore(
  rootReducer,
  initialState,

  // The best part 8)
  Redux.compose(
    Redux.applyMiddleware(ReduxPromiseMiddleware.default()),
    window.devToolsExtension ? window.devToolsExtension() : (v) => v
  )
);

export {store};

但它不是非常令人满意,因为它在运行测试时会导致许多错误,而不是所有的测试套件都会运行。

1 个答案:

答案 0 :(得分:0)

另一种解决方案是将redux-scripts.html导入添加到所有测试文件中,但是,通过更改redux-promise-middleware库可以获得更好的解决方案。在版本4.4.2中,index.js中的import语句现在指向具有文件扩展名的相对路径./isPromise.js。有了这个,我可以在import promiseMiddleware from '../../node_modules/redux-promise-middleware/dist/es/index.js'redux-store.js,我们就是金色。