Closed jacobq closed 4 years ago
Also #188
I was able to get past this first problem by installing pouchdb-adapter-memory
and using it for the test environment:
// config/environment.js
// ...
if (environment === 'test') {
ENV.emberPouch.options = {
adapter: 'memory'
};
// ...
}
// ...
// app/adapters/application.js
import { Adapter } from 'ember-pouch';
import PouchDB from 'pouchdb';
import pouchInMemoryPlugin from 'pouchdb-adapter-memory'; // Note: using ember-auto-import to get this from npm
import config from 'my-app/config/environment';
import { isEmpty } from '@ember/utils';
import { assert } from '@ember/debug';
function createDb() {
const localDb = config.emberPouch.localDb;
assert('emberPouch.localDb must be set', !isEmpty(localDb));
if (config.emberPouch.options && config.emberPouch.options.adapter === "memory") {
PouchDB.plugin(pouchInMemoryPlugin);
}
const db = new PouchDB(localDb, config.emberPouch.options);
if (config.emberPouch.remoteDb) {
let remoteDb = new PouchDB(config.emberPouch.remoteDb);
db.sync(remoteDb, {
live: true,
retry: true
});
}
return db;
}
export default Adapter.extend({
init() {
this._super(...arguments);
this.set('db', createDb());
}
});
However, I now see another problem. Some tests (not the same ones with the previously mentioned problem either) now show this error after they run:
Error: Attempted to handle event
becameError
on <...> while in state root.loaded.saved.
This inFlight
problem has been happening to me too; I’m also finding that a test I have where it saves a model and tries to click a link on the post-save-forwarded index page is failing because it’s unable to find the link. My theory is that the acceptance test is terminating before the route transition, maybe because the promise being returned from Relational Pouch is non-Ember? But I tried wrapping in an RSVP promise to no avail, so my theory isn’t too promising 😐
@backspace I was able to reproduce the problem by manually using the dev tools console, so there must be more to it than just test waiters/synchronization.
ah, okay. I was able to use the waiter technique discussed in this thread to get rid of the inFlight
error but the test still fails for the other reason. If I pauseTest
and then manually resumeTest
, the test passes 😞
Closing since this is mostly a duplicate of #237 #239 (once I worked around those the only problems I had were related to my own app code)
Ref #200 #217, #23, #24
I just switched from
ember-localstorage-adapter
and suddenly lots of tests that were passing now blow up during their tear-down with errors like:Does this addon not support use in testing? Is there a way to easily band-aid this? (e.g. have all the tests run a hook that does something magic?)