Skip to content

Commit

Permalink
Remove gulp from unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS authored and lfdebrux committed May 18, 2022
1 parent c7b690b commit 1ff2e04
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions __tests__/spec/sanity-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const sass = require('sass')
const app = require('../../server.js')
const gulpConfig = require('../../gulp/config.json')
const utils = require('../../lib/utils')
const { generateAssets } = require('../../run-tasks')

function readFile (pathFromRoot) {
return fs.readFileSync(path.join(__dirname, '../../' + pathFromRoot), 'utf8')
Expand All @@ -20,6 +21,10 @@ function readFile (pathFromRoot) {
* Basic sanity checks on the dev server
*/
describe('The Prototype Kit', () => {
beforeAll(() => {
generateAssets()
})

it('should generate assets into the /public folder', () => {
assert.doesNotThrow(function () {
fs.accessSync(path.resolve(__dirname, '../../public/javascripts/application.js'))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test:integration:edge": "start-server-and-test 3000 'cypress run --browser edge'",
"test:integration:chrome": "start-server-and-test 3000 'cypress run --browser chrome'",
"test:integration:electron": "start-server-and-test 3000 'cypress run --browser electron'",
"test": "gulp generate-assets && jest && npm run lint"
"test": "jest && npm run lint"
},
"dependencies": {
"acorn": "^8.5.0",
Expand Down
19 changes: 15 additions & 4 deletions run-tasks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const colour = require('nodemon/lib/utils/colour')
module.exports = function () {

function runTasks () {
clean()
sassExtensions()
// in parallel:
Expand All @@ -10,6 +11,13 @@ module.exports = function () {
runNodemon()
}

function generateAssets () {
clean()
sassExtensions()
sass()
copyAssets()
}

function clean () {
// doesn't clean extensions.scss, should it?
const fs = require('fs')
Expand Down Expand Up @@ -69,9 +77,7 @@ function copyAssets () {

// shouldnt have to mkdir, but copy errors with EEXIST otherwise
fs.mkdirSync('public', { recursive: true })
fs.copy('app/assets', 'public', { filter: filterFunc }, err => {
if (err) return console.error(err)
})
fs.copySync('app/assets', 'public', { filter: filterFunc })
}

function watch () {
Expand Down Expand Up @@ -129,3 +135,8 @@ function runNodemon () {
.on('crash', onCrash)
.on('quit', onQuit)
}

module.exports = {
runTasks,
generateAssets
}
2 changes: 1 addition & 1 deletion start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')
const fs = require('fs')

// Local dependencies
const runTasks = require('./run-tasks')
const { runTasks } = require('./run-tasks')

checkFiles()

Expand Down

0 comments on commit 1ff2e04

Please sign in to comment.