Tests aren't running #1938
-
Hello there. node -r @adonisjs/assembler/build/register japaFile.ts When I execute the command above, everytime I get the error below: internal/modules/cjs/loader.js:1033
throw err;
^
Error: Cannot find module '@adonisjs/assembler/build/register'
Require stack:
- internal/preload
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
at Function.Module._load (internal/modules/cjs/loader.js:899:27)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at Module._preloadModules (internal/modules/cjs/loader.js:1346:12)
at loadPreloadModules (internal/bootstrap/pre_execution.js:439:5)
at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3)
at internal/main/run_main_module.js:7:1 {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]
} Here is my package.json dependencies: "devDependencies": {
"@adonisjs/assembler": "^2.0.0",
"@types/jsdom": "^16.2.4",
"@types/supertest": "^2.0.10",
"adonis-preset-ts": "^1.0.4",
"eslint": "^7.11.0",
"eslint-plugin-adonis": "^1.0.15",
"execa": "^4.0.3",
"get-port": "^5.1.1",
"japa": "^3.1.1",
"jsdom": "^16.4.0",
"pino-pretty": "^4.3.0",
"supertest": "^5.0.0",
"typescript": "^4.0.3",
"youch": "^2.1.1",
"youch-terminal": "^1.0.1"
},
"dependencies": {
"@adonisjs/ace": "^6.0.0",
"@adonisjs/auth": "^4.3.1",
"@adonisjs/core": "5.0.0-preview-rc-1.12",
"@adonisjs/fold": "^6.0.0",
"@adonisjs/lucid": "^8.5.0",
"@adonisjs/shield": "^3.0.8",
"aws-sdk": "^2.783.0",
"luxon": "^1.25.0",
"mysql": "^2.18.1",
"phc-argon2": "^1.0.11",
"proxy-addr": "^2.0.6",
"reflect-metadata": "^0.1.13",
"source-map-support": "^0.5.19"
}
} Here is the test file that its path is test/example.spec.ts: import test from 'japa'
test.group('Example', () => {
test('assert sum', (assert) => {
assert.equal(2 + 2, 4)
})
}) And here is japaFile.ts that is configuration of tests: import 'reflect-metadata'
import getPort from 'get-port'
import { configure } from 'japa'
import sourceMapSupport from 'source-map-support'
import { join, isAbsolute, sep } from 'path'
process.env.ADONIS_ACE_CWD = join(__dirname, '..')
sourceMapSupport.install({ handleUncaughtExceptions: false })
async function startHttpServer () {
const { Ignitor } = await import('@adonisjs/core/build/src/Ignitor')
process.env.PORT = String(await getPort())
await new Ignitor(__dirname).httpServer().start()
}
function getTestFiles () {
let userDefined = process.argv.slice(2)[0]
if (!userDefined) {
return 'build/test/**/*.spec.js'
}
if (isAbsolute(userDefined)) {
userDefined = userDefined.endsWith('.ts')
? userDefined.replace(`${join(__dirname, '..')}${sep}`, '')
: userDefined.replace(`${join(__dirname)}${sep}`, '')
}
return `build/${userDefined.replace(/\.ts$|\.js$/, '')}.js`
}
/**
* Configure test runner
*/
configure({
files: getTestFiles(),
before: [
startHttpServer,
],
after: []
}) By the way, We get a different error on Ubuntu 20.04. I think this problem may be an issue. |
Beta Was this translation helpful? Give feedback.
Answered by
RomainLanz
Nov 20, 2020
Replies: 1 comment 3 replies
-
Hey @remidosol! 👋 You need to update the version of npm i -D @adonisjs/assembler@alpha |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
remidosol
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @remidosol! 👋
You need to update the version of
@adonisjs/assembler
.