From f3ac218c735dd6b9ba662995fa156368464de1c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Mon, 8 Jul 2019 23:42:13 +0200 Subject: [PATCH] Silly cypress cannot deal with `fs` npm module ... a server-side npm package and does not work for the browser. --- backend/src/models/index.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/backend/src/models/index.js b/backend/src/models/index.js index dbf654c68..0e6ae5864 100644 --- a/backend/src/models/index.js +++ b/backend/src/models/index.js @@ -1,13 +1,7 @@ -import fs from 'fs' -import path from 'path' - -const models = {} -fs.readdirSync(__dirname).forEach(file => { - file = path.join(__dirname, file).toString('utf-8') - const name = path.basename(file, '.js') - if (!/\.spec/.test(name) && path.extname(file) === '.js') { - // Is a gql file - models[name] = require(file) - } -}) -export default models +// NOTE: We cannot use `fs` here to clean up the code. Cypress breaks on any npm +// module that is not browser-compatible. Node's `fs` module is server-side only +export default { + User: require('./User.js'), + InvitationCode: require('./InvitationCode.js'), + EmailAddress: require('./EmailAddress.js'), +}