ngrx를 기반으로 Angular2 프로젝트가 생성되었으며 @angular/cli: 1.0.0-beta.32.3
으로 빌드되었습니다. 앱 자체는 공식적으로 지원되는 예제 ngrx 앱 : https://github.com/ngrx/example-app과 공통점이 많습니다.Angular-CLI "ng e2e": ts-node를 사용한 각도기 테스트에서 localStorage가 누락되었습니다.
내가 그렇게 https://github.com/btroncone/ngrx-store-localstorage 패키지를 사용하여 로컬 스토리지와 상점의 일부를 동기화 : 내가있어
const developmentReducer: ActionReducer<State> = compose(
storeFreeze,
combineReducers
)(reducers);
const productionReducer: ActionReducer<State> = combineReducers(reducers);
: 내 reducers/index.ts
파일
원래의 장소에 (원래 https://github.com/ngrx/example-app/blob/master/src/app/reducers/index.ts 모양) 약간 수정 된 버전 :
const developmentReducer: ActionReducer<State> = compose(
storeFreeze,
localStorageSync(['auth'], true),
combineReducers
)(reducers);
const productionReducer: ActionReducer<State> = compose(
localStorageSync(['auth'], true),
combineReducers
)(reducers);
잘 작동하며 전혀 문제가 없습니다.
것은 내가 이 설치로 각도기 e2e 테스트를 실행할 수 없습니다. 이 localStorageSync
은 브라우저의 localStorage
을 기본 인수로 사용합니다. protractor.conf.js
에 명시된 바와 같이하지만, angular-cli's
각도기는 ts-node
사용
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e'
});
},
ng e2e
[19:25:07] I/direct - Using ChromeDriver directly...
[19:25:09] E/launcher - Error: ReferenceError: localStorage is not defined
at Object.exports.localStorageSync (/home/myfolder/e2e-storage-test/node_modules/ngrx-store-localstorage/src/index.ts:118:77)
at Object.<anonymous> (/home/myfolder/e2e-storage-test/src/app/reducers/index.ts:32:3)
at Module._compile (module.js:570:32)
at Module.m._compile (/home/myfolder/e2e-storage-test/node_modules/ts-node/src/index.ts:406:23)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/myfolder/e2e-storage-test/node_modules/ts-node/src/index.ts:409:12)
전체 역 추적 가능 여기 : https://gist.github.com/radoslawroszkowiak/17e53b9043264b6d813df2374e8d4dc8은.
저는이 프로젝트가 서버 측 렌더링에만 사용되고 브라우저 환경 만 사용되는 것을 원하지 않기 때문에 node-localstorage와 같은 것을 망칠 필요가 없습니다.
이 문제를 해결하려면 어떻게합니까?