Skip to content

Instantly share code, notes, and snippets.

@JohnnyBushy
Last active July 12, 2021 10:44
Show Gist options
  • Select an option

  • Save JohnnyBushy/961e319a1800a66585658d08dd4d5ba0 to your computer and use it in GitHub Desktop.

Select an option

Save JohnnyBushy/961e319a1800a66585658d08dd4d5ba0 to your computer and use it in GitHub Desktop.
Teardown issue
import Component from '@glimmer/component';
export default class extends Component {
willDestroy() {
this.args.post.save();
}
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default class extends Model {
@attr('string') content;
}
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class extends Route {
@service store;
model() {
return this.store.createRecord('post', {content: 'Some post content here'});
}
};
<MyComponent @post={{@model}} />
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
module('TODO: put something here', function(hooks) {
setupApplicationTest(hooks);
test('visiting /', async function(assert) {
await visit('/');
assert.equal(currentURL(), '/');
// After the test is complete, there is an error thrown in the console
// Attempted to handle event `willCommit` on <post:null> while in state root.empty.
});
});
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
import { start } from 'ember-qunit';
let attributes = {
rootElement: '#test-root',
autoboot: false
};
attributes = assign(attributes, config.APP);
let application = Application.create(attributes);
setApplication(application);
start();
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0",
"ember-data": "3.18.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment