-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup addon tests #171
Setup addon tests #171
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ | |
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/package.json.ember-try | ||
|
||
test/fixtures |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict'; | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
chai.use(require('chai-fs')); | ||
|
||
const glob = require('glob'); | ||
|
||
const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; | ||
|
||
describe('it builds with ember-cli-fastboot', function() { | ||
this.timeout(300000); | ||
|
||
let app; | ||
|
||
beforeEach(function() { | ||
app = new AddonTestApp(); | ||
|
||
return app | ||
.create('dummy', { skipNpm: true }) | ||
.then(app => | ||
app.editPackageJSON(pkg => { | ||
pkg.devDependencies['ember-cli-fastboot'] = '*'; | ||
}) | ||
) | ||
.then(() => app.run('npm', 'install')); | ||
}); | ||
|
||
it('builds into dist/ember-fetch/fetch-fastboot.js', function() { | ||
return app.runEmberCommand('build').then(function() { | ||
expect(app.filePath('dist/index.html')).to.be.a.file(); | ||
expect(app.filePath('dist/ember-fetch/fastboot-fetch.js')).to.be.a.file(); | ||
expect(app.filePath('dist/assets/dummy-fastboot.js')).to.be.a.file(); | ||
}); | ||
}); | ||
|
||
it('produces a production build with --environment=production', function() { | ||
return app | ||
.runEmberCommand('build', '--environment=production') | ||
.then(function() { | ||
expect(app.filePath('dist/index.html')).to.be.a.file(); | ||
expect(find('dist/ember-fetch/fastboot-fetch-*.js')).to.be.a.file(); | ||
expect(find('dist/ember-fetch/fastboot-fetch-*.js')).to.match( | ||
/fastboot-fetch-\w{32}/, | ||
'file name should contain MD5 fingerprint' | ||
); | ||
|
||
expect(find('dist/assets/dummy-fastboot-*.js')).to.be.a.file(); | ||
expect(find('dist/assets/dummy-fastboot-*.js')).to.match( | ||
/dummy-fastboot-\w{32}/, | ||
'file name should contain MD5 fingerprint' | ||
); | ||
}); | ||
}); | ||
|
||
function find(globPath) { | ||
globPath = app.filePath(globPath); | ||
let files = glob.sync(globPath); | ||
|
||
expect(files.length).to.equal(1, globPath); | ||
|
||
return files[0]; | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
const request = require('request'); | ||
const get = require('rsvp').denodeify(request); | ||
const chai = require('chai'); | ||
const expect = chai.expect; | ||
chai.use(require('chai-fs')); | ||
|
||
const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; | ||
|
||
describe('renders in fastboot build', function() { | ||
this.timeout(300000); | ||
|
||
let app; | ||
|
||
beforeEach(function() { | ||
app = new AddonTestApp(); | ||
|
||
return app | ||
.create('dummy', { skipNpm: true }) | ||
.then(app => | ||
app.editPackageJSON(pkg => { | ||
pkg.devDependencies['ember-cli-fastboot'] = '*'; | ||
// These 2 are in ember-fetch's package.json, symlinking to dummy won't help resolve | ||
pkg.devDependencies['abortcontroller-polyfill'] = '*'; | ||
pkg.devDependencies['node-fetch'] = '*'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand. Why are these needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See this PR, |
||
}) | ||
) | ||
.then(function() { | ||
return app.run('npm', 'install'); | ||
}) | ||
.then(function() { | ||
return app.startServer({ | ||
command: 'serve' | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
return app.stopServer(); | ||
}); | ||
|
||
it('fetches in fastboot mode', function() { | ||
return get({ | ||
url: 'http://localhost:49741/', | ||
headers: { | ||
Accept: 'text/html' | ||
} | ||
}).then(function(response) { | ||
expect(response.body).to.contain('Hello World! fetch'); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Application from '@ember/application'; | ||
import Resolver from './resolver'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import config from './config/environment'; | ||
|
||
const App = Application.extend({ | ||
modulePrefix: config.modulePrefix, | ||
podModulePrefix: config.podModulePrefix, | ||
Resolver | ||
}); | ||
|
||
loadInitializers(App, config.modulePrefix); | ||
|
||
export default App; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where are these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are used by |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>Dummy</title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
{{content-for "head"}} | ||
|
||
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css"> | ||
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css"> | ||
|
||
{{content-for "head-footer"}} | ||
</head> | ||
<body> | ||
{{content-for "body"}} | ||
|
||
<script src="{{rootURL}}assets/vendor.js"></script> | ||
<script src="{{rootURL}}assets/dummy.js"></script> | ||
|
||
{{content-for "body-footer"}} | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Resolver from 'ember-resolver'; | ||
|
||
export default Resolver; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import EmberRouter from '@ember/routing/router'; | ||
import config from './config/environment'; | ||
|
||
const Router = EmberRouter.extend({ | ||
location: config.locationType, | ||
rootURL: config.rootURL | ||
}); | ||
|
||
Router.map(function() { | ||
}); | ||
|
||
export default Router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Route from '@ember/routing/route'; | ||
import { hash } from 'rsvp'; | ||
import fetch from 'fetch'; | ||
import ajax from 'ember-fetch/ajax'; | ||
|
||
export default Route.extend({ | ||
model: function() { | ||
return hash({ | ||
fetch: fetch('/omg.json').then(function(request) { | ||
return request.json(); | ||
}), | ||
ajax: ajax('/omg.json') | ||
}); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h2 id="title">Welcome to Ember</h2> | ||
|
||
{{outlet}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="fetch"> | ||
Hello {{model.fetch.name}}! fetch | ||
</div> | ||
|
||
<div class="ajax"> | ||
Hello {{model.ajax.name}}! ajax | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
|
||
module.exports = function(environment) { | ||
let ENV = { | ||
modulePrefix: 'dummy', | ||
environment, | ||
rootURL: '/', | ||
locationType: 'auto', | ||
EmberENV: { | ||
FEATURES: { | ||
// Here you can enable experimental features on an ember canary build | ||
// e.g. 'with-controller': true | ||
}, | ||
EXTEND_PROTOTYPES: { | ||
// Prevent Ember Data from overriding Date.parse. | ||
Date: false | ||
} | ||
}, | ||
|
||
APP: { | ||
// Here you can pass flags/options to your application instance | ||
// when it is created | ||
}, | ||
|
||
fastboot: { | ||
hostWhitelist: [/^localhost:\d+$/] | ||
} | ||
}; | ||
|
||
if (environment === 'development') { | ||
// ENV.APP.LOG_RESOLVER = true; | ||
// ENV.APP.LOG_ACTIVE_GENERATION = true; | ||
// ENV.APP.LOG_TRANSITIONS = true; | ||
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true; | ||
// ENV.APP.LOG_VIEW_LOOKUPS = true; | ||
} | ||
|
||
if (environment === 'test') { | ||
// Testem prefers this... | ||
ENV.locationType = 'none'; | ||
|
||
// keep test console output quieter | ||
ENV.APP.LOG_ACTIVE_GENERATION = false; | ||
ENV.APP.LOG_VIEW_LOOKUPS = false; | ||
|
||
ENV.APP.rootElement = '#ember-testing'; | ||
ENV.APP.autoboot = false; | ||
} | ||
|
||
if (environment === 'production') { | ||
// here you can enable a production-specific feature | ||
} | ||
|
||
return ENV; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const browsers = [ | ||
'last 1 Chrome versions', | ||
'last 1 Firefox versions', | ||
'last 1 Safari versions' | ||
]; | ||
|
||
const isCI = !!process.env.CI; | ||
const isProduction = process.env.EMBER_ENV === 'production'; | ||
|
||
if (isCI || isProduction) { | ||
browsers.push('ie 11'); | ||
} | ||
|
||
module.exports = { | ||
browsers | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const EmberApp = require('ember-cli/lib/broccoli/ember-app'); | ||
|
||
module.exports = function(defaults) { | ||
let app = new EmberApp(defaults, { | ||
// Add options here | ||
'ember-fetch': { | ||
} | ||
}); | ||
return app.toTree(); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "World" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# http://www.robotstxt.org | ||
User-agent: * | ||
Disallow: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this to npm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a known issue tomdale/ember-cli-addon-tests#198, should be fixed by a WIP PR tomdale/ember-cli-addon-tests#105