Skip to content

Commit d182d94

Browse files
authored
Merge pull request angular-fullstack#2472 from angular-fullstack/test-perf
Test perf
2 parents 362a04b + d42d0b6 commit d182d94

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

circle.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ dependencies:
2525
- "docs/node_modules"
2626
override:
2727
- npm i
28+
# - gulp build # npm 5 won't run `prepublish` on `npm i`, we will need to re-enable this once we go to a Node version using npm 5+
2829
- cd docs && npm i
2930
- gulp updateFixtures:test
30-
- gulp installFixtures
31-
post:
32-
- gulp build
31+
- cd test/fixtures && npm i && npm run-script update-webdriver
3332

3433
test:
3534
override:

src/test/endpoint.test.js

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22
import path from 'path';
33
import fs from 'fs';
4-
import _ from 'lodash';
54
import Promise from 'bluebird';
65
import helpers from 'yeoman-test';
76
import assert from 'yeoman-assert';
@@ -10,7 +9,6 @@ import * as getExpectedFiles from './get-expected-files';
109
import {
1110
copyAsync,
1211
runCmd,
13-
assertOnlyFiles,
1412
readJSON,
1513
runGen
1614
} from './test-helpers';
@@ -67,27 +65,34 @@ function runEndpointGen(name, opt={}) {
6765
});
6866
}
6967

70-
let eslintCmd = path.join(TEST_DIR, '/fixtures/node_modules/.bin/eslint');
71-
function testFile(command, _path) {
72-
_path = path.normalize(_path);
73-
return fs.accessAsync(_path, fs.R_OK).then(() => {
74-
return runCmd(`${command} ${_path}`);
75-
});
68+
const ESLINT_CMD = path.join(TEST_DIR, '/fixtures/node_modules/.bin/eslint');
69+
70+
/**
71+
* @param {string[]} files
72+
* @param {string} [flags]
73+
*/
74+
function eslintFiles(files, flags = '') {
75+
return runCmd(`${ESLINT_CMD} ${flags} ${files.join(' ')}`);
7676
}
7777

7878
function eslintDir(dir, name, folder) {
7979
if(!folder) folder = name;
8080
let endpointDir = path.join(dir, 'server/api', folder);
81+
let files = fs.readdirAsync(endpointDir);
8182

82-
let regFiles = fs.readdirAsync(endpointDir)
83+
let regFiles = files
8384
.then(files => files.filter(file => minimatch(file, '**/!(*.spec|*.mock|*.integration).js', {dot: true})))
84-
.map(file => testFile(eslintCmd, path.join('./server/api/', folder, file)));
85+
.then(files => files.map(file => path.join('./server/api/', folder, file)));
8586

86-
let specFiles = fs.readdirAsync(endpointDir)
87+
let specFiles = files
8788
.then(files => files.filter(file => minimatch(file, '**/+(*.spec|*.mock|*.integration).js', {dot: true})))
88-
.map(file => testFile(`${eslintCmd} --env node,es6,mocha --global sinon,expect`, path.join('./server/api/', folder, file)));
89+
.then(files => files.map(file => path.join('./server/api/', folder, file)));
90+
91+
let regLint = regFiles.then(files => eslintFiles(files));
92+
93+
let specLint = specFiles.then(files => eslintFiles(files, '--env node,es6,mocha --global sinon,expect'));
8994

90-
return Promise.all([regFiles, specFiles]);
95+
return Promise.all([regLint, specLint]);
9196
}
9297

9398
var config;
@@ -109,7 +114,7 @@ describe('angular-fullstack:endpoint', function() {
109114
]);
110115
});
111116

112-
describe(`with a generated endpont 'foo'`, function() {
117+
describe(`with a generated endpoint 'foo'`, function() {
113118
var dir;
114119
beforeEach(function() {
115120
return runEndpointGen('foo', {config: config['generator-angular-fullstack']}).then(_dir => {
@@ -131,7 +136,7 @@ describe('angular-fullstack:endpoint', function() {
131136
});
132137
});
133138

134-
describe('with a generated capitalized endpont', function() {
139+
describe('with a generated capitalized endpoint', function() {
135140
var dir;
136141
beforeEach(function() {
137142
return runEndpointGen('Foo', {config: config['generator-angular-fullstack']}).then(_dir => {
@@ -153,7 +158,7 @@ describe('angular-fullstack:endpoint', function() {
153158
});
154159
});
155160

156-
describe('with a generated path name endpont', function() {
161+
describe('with a generated path name endpoint', function() {
157162
var dir;
158163
beforeEach(function() {
159164
return runEndpointGen('foo/bar', {config: config['generator-angular-fullstack']}).then(_dir => {

src/test/main.test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('angular-fullstack:app', function() {
5858
describe('default settings', function() {
5959
var dir;
6060

61-
beforeEach(function() {
61+
before(function() {
6262
return runGen(defaultOptions).then(_dir => {
6363
dir = _dir;
6464
});
@@ -83,7 +83,7 @@ describe('angular-fullstack:app', function() {
8383
});
8484

8585
describe('with a generated endpoint', function() {
86-
beforeEach(function() {
86+
before(function() {
8787
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
8888
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
8989
});
@@ -95,9 +95,9 @@ describe('angular-fullstack:app', function() {
9595
});
9696

9797
describe('with a generated capitalized endpoint', function() {
98-
beforeEach(function() {
98+
before(function() {
9999
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
100-
return runEndpointGen('Foo', {config: config['generator-angular-fullstack']});
100+
return runEndpointGen('Bar', {config: config['generator-angular-fullstack']});
101101
});
102102
});
103103

@@ -107,9 +107,9 @@ describe('angular-fullstack:app', function() {
107107
});
108108

109109
describe('with a generated path name endpoint', function() {
110-
beforeEach(function() {
110+
before(function() {
111111
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
112-
return runEndpointGen('foo/bar', {config: config['generator-angular-fullstack']});
112+
return runEndpointGen('foo/baz', {config: config['generator-angular-fullstack']});
113113
});
114114
});
115115

@@ -119,9 +119,9 @@ describe('angular-fullstack:app', function() {
119119
});
120120

121121
describe('with a generated snake-case endpoint', function() {
122-
beforeEach(function() {
122+
before(function() {
123123
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
124-
return runEndpointGen('foo-bar', {config: config['generator-angular-fullstack']});
124+
return runEndpointGen('foo-boo', {config: config['generator-angular-fullstack']});
125125
});
126126
});
127127

@@ -231,7 +231,7 @@ describe('angular-fullstack:app', function() {
231231
});
232232

233233
describe('with a generated endpoint', function() {
234-
beforeEach(function() {
234+
before(function() {
235235
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
236236
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
237237
});
@@ -276,7 +276,7 @@ describe('angular-fullstack:app', function() {
276276
};
277277
this.retries(3); // Sequelize seems to be quite flaky
278278

279-
beforeEach(function() {
279+
before(function() {
280280
return runGen(testOptions).then(_dir => {
281281
dir = _dir;
282282
lintResult = runCmd('gulp lint:scripts');
@@ -303,7 +303,7 @@ describe('angular-fullstack:app', function() {
303303
});
304304

305305
describe.skip('with a generated endpoint', function() {
306-
beforeEach(function() {
306+
before(function() {
307307
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
308308
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
309309
});
@@ -348,7 +348,7 @@ describe('angular-fullstack:app', function() {
348348
uibootstrap: false
349349
};
350350

351-
beforeEach(function() {
351+
before(function() {
352352
return runGen(testOptions, {options: {devPort: '9005'}}).then(_dir => {
353353
dir = _dir;
354354
lintResult = runCmd('gulp lint:scripts');
@@ -376,7 +376,7 @@ describe('angular-fullstack:app', function() {
376376
});
377377

378378
describe('with a generated endpoint', function() {
379-
beforeEach(function() {
379+
before(function() {
380380
return readJSON(path.join(dir, '.yo-rc.json')).then(config => {
381381
return runEndpointGen('foo', {config: config['generator-angular-fullstack']});
382382
});

0 commit comments

Comments
 (0)