Skip to content

Commit 3a1c3e1

Browse files
committed
fix(jest): fix problem where test suite was not running on CI
1 parent 4a108d4 commit 3a1c3e1

File tree

5 files changed

+46
-56
lines changed

5 files changed

+46
-56
lines changed

config/setup.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"homepage": "https://github.com/brysgo/graphql-bookshelf#readme",
2929
"devDependencies": {
3030
"babel-cli": "^6.6.5",
31-
"babel-jest": "^20.0.0",
31+
"babel-jest": "^20.0.3",
3232
"babel-polyfill": "^6.7.4",
3333
"babel-preset-es2015": "^6.6.0",
3434
"babel-preset-stage-0": "^6.5.0",
@@ -38,18 +38,16 @@
3838
"graphql-relay": "^0.5.1",
3939
"jest-cli": "^20.0.0",
4040
"knex": "^0.13.0",
41-
"sqlite3": "^3.0.10"
41+
"regenerator-runtime": "^0.10.5",
42+
"sqlite3": "^3.1.8"
4243
},
4344
"jest": {
44-
"unmockedModulePathPatterns": [
45-
".*"
46-
],
47-
"testDirectoryName": "specs",
48-
"testPathDirs": [
45+
"roots": [
4946
"<rootDir>/specs"
5047
],
51-
"setupEnvScriptFile": "<rootDir>/config/env.js",
52-
"setupTestFrameworkScriptFile": "<rootDir>/config/setup.js"
48+
"setupFiles": [
49+
"<rootDir>/config/env.js"
50+
]
5351
},
5452
"peerDependencies": {
5553
"bookshelf": "^0.10.0",

specs/attr-test.js renamed to specs/attr.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import graphqlWithSchema from '../schema';
55
describe('attr', function() {
66

77
describe('on a bookshelf table attribute', function() {
8-
it('returns the attribute', function* () {
9-
yield clean();
10-
var student = yield Student.forge({name: 'Marty Finklestein'}).save();
8+
it('returns the attribute', async function () {
9+
await clean();
10+
var student = await Student.forge({name: 'Marty Finklestein'}).save();
1111

1212
let query = `{
1313
viewer(id: ${student.get('id')}) {
1414
name
1515
}
1616
}`
1717

18-
var results = yield graphqlWithSchema(query);
18+
var results = await graphqlWithSchema(query);
1919

2020
expect(results).toEqual({
2121
data: {

specs/belongsTo-test.js renamed to specs/belongsTo.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import graphqlWithSchema from '../schema';
55
describe('belongsTo', function() {
66

77
describe('on a bookshelf belongsTo', function() {
8-
it('returns associated content', function* () {
9-
yield clean();
10-
var student = yield Student.forge().save();
11-
var homework = yield student.homeworks().create();
12-
var classroom = yield Classroom.forge().save();
13-
yield homework.set('classroom_id', classroom.get('id')).save();
8+
it('returns associated content', async function () {
9+
await clean();
10+
var student = await Student.forge().save();
11+
var homework = await student.homeworks().create();
12+
var classroom = await Classroom.forge().save();
13+
await homework.set('classroom_id', classroom.get('id')).save();
1414

1515
let query = `{
1616
viewer(id: ${student.get('id')}) {
@@ -22,7 +22,7 @@ describe('belongsTo', function() {
2222
}
2323
}`
2424

25-
var results = yield graphqlWithSchema(query);
25+
var results = await graphqlWithSchema(query);
2626

2727
expect(results).toEqual({
2828
data: {

specs/hasMany-test.js renamed to specs/hasMany.test.js

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import graphqlWithSchema from '../schema';
55
describe('hasMany', function() {
66

77
describe('with a resolve function', function() {
8-
it('passes a KnexJS query builder through to the resolve', function* () {
9-
yield clean();
10-
var student = yield Student.forge({name: 'Joe Shmoe'}).save();
11-
var classroom1 = yield student.classrooms().create();
12-
var classroom2 = yield student.classrooms().create();
8+
it('passes a KnexJS query builder through to the resolve', async function () {
9+
await clean();
10+
var student = await Student.forge({name: 'Joe Shmoe'}).save();
11+
var classroom1 = await student.classrooms().create();
12+
var classroom2 = await student.classrooms().create();
1313

1414
let query = `{
1515
viewer(id: ${student.get('id')}) {
@@ -19,7 +19,7 @@ describe('hasMany', function() {
1919
}
2020
}`
2121

22-
const results = yield graphqlWithSchema(query);
22+
const results = await graphqlWithSchema(query);
2323

2424
expect(results).toEqual({
2525
data: {
@@ -32,12 +32,12 @@ describe('hasMany', function() {
3232
});
3333

3434
describe('without a resolve function', function() {
35-
it('returns bookshelf belongsToMany associated data', function* () {
36-
yield clean();
37-
var student = yield Student.forge({name: 'Joe Shmoe'}).save();
38-
var classroom1 = yield student.classrooms().create();
39-
var classroom2 = yield student.classrooms().create();
40-
var student2 = yield classroom2.students().create({name: 'Marvin Martian'});
35+
it('returns bookshelf belongsToMany associated data', async function () {
36+
await clean();
37+
var student = await Student.forge({name: 'Joe Shmoe'}).save();
38+
var classroom1 = await student.classrooms().create();
39+
var classroom2 = await student.classrooms().create();
40+
var student2 = await classroom2.students().create({name: 'Marvin Martian'});
4141

4242
let query = `{
4343
viewer(id: ${student.get('id')}) {
@@ -47,7 +47,7 @@ describe('hasMany', function() {
4747
}
4848
}`
4949

50-
const results = yield graphqlWithSchema(query);
50+
const results = await graphqlWithSchema(query);
5151

5252
expect(results).toEqual({
5353
data: {
@@ -58,19 +58,20 @@ describe('hasMany', function() {
5858
});
5959
let { classrooms } = results.data.viewer;
6060

61-
expect(classrooms).toContain({ id: classroom1.get('id') });
62-
expect(classrooms).toContain({ id: classroom2.get('id') });
61+
const stripped = classrooms.map(({id}) => id);
62+
expect(stripped).toContain(classroom1.get('id'));
63+
expect(stripped).toContain(classroom2.get('id'));
6364
});
64-
65+
6566
});
66-
67+
6768
describe('with a relay connection type', function() {
68-
it('returns a connection instead of an array', function* () {
69-
yield clean();
70-
var student = yield Student.forge({name: 'Joe Shmoe'}).save();
71-
var classroom = yield student.classrooms().create();
72-
var homework1 = yield classroom.homeworks().create({content: 'I did it...'});
73-
var homework2 = yield classroom.homeworks().create({content: 'Look!!!'});
69+
it('returns a connection instead of an array', async function () {
70+
await clean();
71+
var student = await Student.forge({name: 'Joe Shmoe'}).save();
72+
var classroom = await student.classrooms().create();
73+
var homework1 = await classroom.homeworks().create({content: 'I did it...'});
74+
var homework2 = await classroom.homeworks().create({content: 'Look!!!'});
7475

7576
let query = `{
7677
viewer(id: ${student.get('id')}) {
@@ -86,7 +87,7 @@ describe('hasMany', function() {
8687
}
8788
}`
8889

89-
const results = yield graphqlWithSchema(query);
90+
const results = await graphqlWithSchema(query);
9091

9192
expect(results).toEqual({
9293
data: {
@@ -100,9 +101,9 @@ describe('hasMany', function() {
100101
}
101102
});
102103
let { edges } = results.data.viewer.classrooms[0].homeworks;
103-
104-
expect(edges).toContain({ node: { content: homework1.get('content') }});
105-
expect(edges).toContain({ node: { content: homework2.get('content') }});
104+
const stripped = edges.map(({node: {content}}) => content);
105+
expect(stripped).toContain(homework1.get('content'));
106+
expect(stripped).toContain(homework2.get('content'));
106107
});
107108
});
108109
});

0 commit comments

Comments
 (0)