Skip to content

Instantly share code, notes, and snippets.

@TimFletcher
Last active August 19, 2016 20:16
Show Gist options
  • Save TimFletcher/24c577f2355295bfb5e887700169d2da to your computer and use it in GitHub Desktop.
Save TimFletcher/24c577f2355295bfb5e887700169d2da to your computer and use it in GitHub Desktop.
Chimp login fixtures problem
export default {
users: {
create() {
server.execute(() => {
const email = 'test@example.com';
const password = 'jkjkjkjk';
let userId;
try {
const user = Meteor.users.findOne({ emails: { $elemMatch: { address: email } } });
userId = user._id;
} catch (e) {
userId = Accounts.createUser({
username: 'test',
email,
password,
profile: { firstName: 'Tim', lastName: 'Fletcher' },
});
}
// Always reset user password as a test may have changed it
Accounts.setPassword(userId, password, { logout: false });
});
},
serverLogin(user) {
server.call('login', { user: { email: user.email }, password: user.password });
},
clientLogin(accountHolder) {
browser.url('http://localhost:3100'); // the client must be on a Meteor app page before you can call `execute` on it
browser.executeAsync(function(accountHolder, done){
Meteor.loginWithPassword(accountHolder.email, accountHolder.password, done);
}, accountHolder);
},
login(user) {
this.serverLogin(user);
this.clientLogin(user);
},
},
common: {
reset() {
// Make sure the DDP connection is not logged in before clearing the database
server.call('logout');
server.execute(() => { Package['xolvio:cleaner'].resetDatabase(); });
},
},
};
[chimp] Running...
Change Password Form
1) "before each" hook
0 passing (3s)
1 failing
1) Change Password Form "before each" hook:
Uncaught Error: asynchronous script timeout: result was not received in 0 seconds
at Object.Future.wait (node_modules/fibers/future.js:449:15)
at Object.<anonymous> (node_modules/wdio-sync/build/index.js:345:27)
at Object.clientLogin (fixtures.js:42:15)
at Object.login (fixtures.js:49:12)
at Context.<anonymous> (change_password.js:13:20)
at node_modules/chimp/dist/lib/utils/fiberize.js:25:14
- - - - -
import fixtures from './fixtures';
describe('Change Password Form', () => {
beforeEach(() => {
fixtures.common.reset();
fixtures.users.create();
fixtures.users.login({ email: 'test@example.com', password: 'jkjkjkjk' });
});
it('can change password @watch', () => {
browser.execute(function(done){
console.log('never gets here....');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment