My question is how i can use @ionic/storage in E2E tests. In my page, i do like this:
import { Storage } from '@ionic/storage';
..
constructor(
private storage: Storage
) { .. }
Then in this page i can use storage like this:
this.storage.set("somevalue", "the actiual value");
and
this.storage.get("somevalue")
I’ve tried to import and use @ionic/storage in the E2E test script, but i don’t see how i can use it there.
Tried it this way:
import {Storage} from '@ionic/storage';
describe('Dashboard E2E test', () => {
beforeEach(() => {
let storageConfig = { name: 'somename' };
let storage: Storage = new Storage(storageConfig);
this.storage.get("somevalue").subscribe(res => {
..
})
when trying to run tests, i get this:
[13:29:41] I/launcher - Running 1 instances of WebDriver
[13:29:41] I/direct - Using ChromeDriver directly...
[13:29:42] E/launcher - Error: /Users/xxxx/dev/nnnn/node_modules/@ionic/storage/dist/index.js:1
(function (exports, require, module, __filename, __dirname) { import { NgModule } from '@angular/core';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/xxxx/dev/nnnn/src/pages/dashboard/dashboard.e2e-spec.ts:5:17)
[13:29:42] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 4
npm ERR! nnnn@0.0.2 e2e-test: `protractor ./test-config/protractor.conf.js`
npm ERR! Exit status 4
npm ERR!
npm ERR! Failed at the nnnn@0.0.2 e2e-test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xxxx/.npm/_logs/2019-01-31T12_29_42_759Z-debug.log
I’m not sure if this clarifies what my question is. and maybe it’s even a stupid question. I just don’t see how i am supposed to do this. So I could use a pointer in the right direction.