mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
refactor: move tests to unit folder
This commit is contained in:
parent
0e0729ddff
commit
db637c4d32
@ -43,8 +43,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build-fixtures && npm run test:unit",
|
"test": "npm run build-fixtures && npm run test:unit",
|
||||||
"build-fixtures": "node ./scripts/build-fixtures",
|
"build-fixtures": "node ./scripts/build-fixtures",
|
||||||
"test:unit": "jest --maxWorkers=4 test/*.test.js",
|
"test:unit": "jest --maxWorkers=4 test/unit",
|
||||||
"test:e2e": "jest --maxWorkers=1 test/e2e/*.test.js",
|
"test:e2e": "jest --maxWorkers=1 test/e2e",
|
||||||
"coverage": "codecov",
|
"coverage": "codecov",
|
||||||
"lint": "eslint --ext .js,.mjs,.vue bin/* build/ lib/ test/ examples/",
|
"lint": "eslint --ext .js,.mjs,.vue bin/* build/ lib/ test/ examples/",
|
||||||
"precommit": "npm run lint",
|
"precommit": "npm run lint",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { Nuxt, Options } from '..'
|
import { Nuxt, Options } from '../../'
|
||||||
import { version } from '../package.json'
|
import { version } from '../../package.json'
|
||||||
|
|
||||||
describe('basic config defaults', () => {
|
describe('basic config defaults', () => {
|
||||||
test('Nuxt.version is same as package', () => {
|
test('Nuxt.version is same as package', () => {
|
||||||
@ -9,7 +9,7 @@ describe('basic config defaults', () => {
|
|||||||
|
|
||||||
test('modulesDir uses /node_modules as default if not set', async () => {
|
test('modulesDir uses /node_modules as default if not set', async () => {
|
||||||
const options = Options.from({})
|
const options = Options.from({})
|
||||||
const currentNodeModulesDir = resolve(__dirname, '..', 'node_modules')
|
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
|
||||||
expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
|
expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
@ -1,5 +1,5 @@
|
|||||||
import { Nuxt, Builder } from '..'
|
import { Nuxt, Builder } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,5 +1,5 @@
|
|||||||
import { Nuxt, Generator } from '..'
|
import { Nuxt, Generator } from '../../'
|
||||||
import { loadFixture } from './utils'
|
import { loadFixture } from '../utils'
|
||||||
|
|
||||||
describe('basic fail generate', () => {
|
describe('basic fail generate', () => {
|
||||||
test('Fail with routes() which throw an error', async () => {
|
test('Fail with routes() which throw an error', async () => {
|
@ -5,12 +5,12 @@ import { remove } from 'fs-extra'
|
|||||||
import serveStatic from 'serve-static'
|
import serveStatic from 'serve-static'
|
||||||
import finalhandler from 'finalhandler'
|
import finalhandler from 'finalhandler'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt, Generator } from '..'
|
import { Nuxt, Generator } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
const rootDir = resolve(__dirname, 'fixtures/basic')
|
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
|
||||||
const distDir = resolve(rootDir, '.nuxt-generate')
|
const distDir = resolve(rootDir, '.nuxt-generate')
|
||||||
|
|
||||||
let nuxt = null
|
let nuxt = null
|
@ -1,6 +1,6 @@
|
|||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,6 +1,6 @@
|
|||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,5 +1,5 @@
|
|||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
// const url = (route) => 'http://localhost:' + port + route
|
// const url = (route) => 'http://localhost:' + port + route
|
@ -2,15 +2,15 @@ import { exec, spawn } from 'child_process'
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Utils } from '..'
|
import { Utils } from '../../'
|
||||||
|
|
||||||
const execify = promisify(exec)
|
const execify = promisify(exec)
|
||||||
const rootDir = resolve(__dirname, 'fixtures/basic')
|
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
|
||||||
const nuxtBin = resolve(__dirname, '..', 'bin', 'nuxt')
|
const nuxtBin = resolve(__dirname, '..', '..', 'bin', 'nuxt')
|
||||||
|
|
||||||
describe.skip('cli', () => {
|
describe.skip('cli', () => {
|
||||||
test('nuxt build', async () => {
|
test('nuxt build', async () => {
|
@ -1,6 +1,6 @@
|
|||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,6 +1,6 @@
|
|||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,5 +1,5 @@
|
|||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
|
|
@ -7,7 +7,7 @@ const readFile = promisify(fs.readFile)
|
|||||||
describe('dynamic routes', () => {
|
describe('dynamic routes', () => {
|
||||||
test('Check .nuxt/router.js', () => {
|
test('Check .nuxt/router.js', () => {
|
||||||
return readFile(
|
return readFile(
|
||||||
resolve(__dirname, './fixtures/dynamic-routes/.nuxt/router.js'),
|
resolve(__dirname, '..', 'fixtures/dynamic-routes/.nuxt/router.js'),
|
||||||
'utf-8'
|
'utf-8'
|
||||||
).then(routerFile => {
|
).then(routerFile => {
|
||||||
routerFile = routerFile
|
routerFile = routerFile
|
@ -1,6 +1,6 @@
|
|||||||
// import rp from 'request-promise-native'
|
// import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,7 +1,7 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -4,12 +4,12 @@ import { resolve } from 'path'
|
|||||||
import serveStatic from 'serve-static'
|
import serveStatic from 'serve-static'
|
||||||
import finalhandler from 'finalhandler'
|
import finalhandler from 'finalhandler'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt, Generator, Options } from '..'
|
import { Nuxt, Generator, Options } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
const distDir = resolve(__dirname, 'fixtures/basic/.nuxt-generate-fallback')
|
const distDir = resolve(__dirname, '..', 'fixtures/basic/.nuxt-generate-fallback')
|
||||||
|
|
||||||
let nuxt = null
|
let nuxt = null
|
||||||
let server = null
|
let server = null
|
@ -1,4 +1,4 @@
|
|||||||
import { Nuxt, Generator } from '..'
|
import { Nuxt, Generator } from '../../'
|
||||||
|
|
||||||
describe('generator', () => {
|
describe('generator', () => {
|
||||||
test('initRoutes with routes (fn => array)', async () => {
|
test('initRoutes with routes (fn => array)', async () => {
|
@ -1,7 +1,7 @@
|
|||||||
import { normalize } from 'path'
|
import { normalize } from 'path'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
@ -1,6 +1,6 @@
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { Nuxt, Builder } from '..'
|
import { Nuxt, Builder } from '../../'
|
||||||
import { loadFixture } from './utils'
|
import { loadFixture } from '../utils'
|
||||||
|
|
||||||
describe('nuxt', () => {
|
describe('nuxt', () => {
|
||||||
test('Nuxt.js Class', () => {
|
test('Nuxt.js Class', () => {
|
||||||
@ -23,7 +23,7 @@ describe('nuxt', () => {
|
|||||||
test('Fail to build when no pages/ directory but is in the parent', () => {
|
test('Fail to build when no pages/ directory but is in the parent', () => {
|
||||||
const nuxt = new Nuxt({
|
const nuxt = new Nuxt({
|
||||||
dev: false,
|
dev: false,
|
||||||
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
|
rootDir: resolve(__dirname, '..', 'fixtures', 'empty', 'pages')
|
||||||
})
|
})
|
||||||
|
|
||||||
return new Builder(nuxt).build().catch(err => {
|
return new Builder(nuxt).build().catch(err => {
|
@ -1,5 +1,5 @@
|
|||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let nuxt = null
|
let nuxt = null
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
import { Nuxt, Utils } from '..'
|
import { Nuxt, Utils } from '../../'
|
||||||
import { uniq } from 'lodash'
|
import { uniq } from 'lodash'
|
||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
let nuxt = null
|
let nuxt = null
|
@ -1,5 +1,5 @@
|
|||||||
import ansiHTML from 'ansi-html'
|
import ansiHTML from 'ansi-html'
|
||||||
import { Utils } from '..'
|
import { Utils } from '../../'
|
||||||
|
|
||||||
describe('utils', () => {
|
describe('utils', () => {
|
||||||
test('encodeHtml', () => {
|
test('encodeHtml', () => {
|
@ -1,6 +1,6 @@
|
|||||||
import rp from 'request-promise-native'
|
import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '..'
|
import { Nuxt } from '../../'
|
||||||
import { loadFixture, getPort } from './utils'
|
import { loadFixture, getPort } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
Loading…
Reference in New Issue
Block a user