mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
reogranize tests
This commit is contained in:
parent
9b7b25a3b9
commit
23949400dc
@ -3,7 +3,7 @@
|
||||
module.exports = {
|
||||
setupFilesAfterEnv: [__dirname + '/test/unit.setup.js'],
|
||||
modulePathIgnorePatterns: ['.cache', 'dist'],
|
||||
testPathIgnorePatterns: ['.testdata.js', '.test.utils.js'],
|
||||
testPathIgnorePatterns: ['.testdata.js', '.test.utils.[jt]s'],
|
||||
testMatch: ['/**/__tests__/**/*.[jt]s?(x)'],
|
||||
// Use `jest-watch-typeahead` version 0.6.5. Newest version 1.0.0 does not support jest@26
|
||||
// Reference: https://github.com/jest-community/jest-watch-typeahead/releases/tag/v1.0.0
|
||||
|
@ -24,7 +24,7 @@ const mock = {
|
||||
admin,
|
||||
};
|
||||
|
||||
jest.mock('../../index', () => {
|
||||
jest.mock('@strapi/strapi', () => {
|
||||
const impl = jest.fn(() => mock);
|
||||
|
||||
impl.compile = jest.fn();
|
||||
@ -33,7 +33,7 @@ jest.mock('../../index', () => {
|
||||
});
|
||||
|
||||
const inquirer = require('inquirer');
|
||||
const createAdminCommand = require('../actions/admin/create-user/action');
|
||||
const createAdminCommand = require('../action');
|
||||
|
||||
describe('admin:create command', () => {
|
||||
beforeEach(() => {
|
@ -15,7 +15,7 @@ const mock = {
|
||||
admin,
|
||||
};
|
||||
|
||||
jest.mock('../../index', () => {
|
||||
jest.mock('@strapi/strapi', () => {
|
||||
const impl = jest.fn(() => mock);
|
||||
|
||||
impl.compile = jest.fn();
|
||||
@ -24,7 +24,7 @@ jest.mock('../../index', () => {
|
||||
});
|
||||
|
||||
const inquirer = require('inquirer');
|
||||
const resetAdminPasswordCommand = require('../actions/admin/reset-user-password/action');
|
||||
const resetAdminPasswordCommand = require('../action');
|
||||
|
||||
describe('admin:reset-password command', () => {
|
||||
beforeEach(() => {
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { expectExit } = require('./utils/data-transfer.test.utils');
|
||||
const { expectExit } = require('../../../__tests__/commands.test.utils');
|
||||
|
||||
describe('Export', () => {
|
||||
const defaultFileName = 'defaultFilename';
|
||||
@ -54,7 +54,7 @@ describe('Export', () => {
|
||||
|
||||
jest.mock('@strapi/data-transfer', () => mockDataTransfer);
|
||||
|
||||
// mock utils
|
||||
// command utils
|
||||
const mockUtils = {
|
||||
loadersFactory: jest.fn().mockReturnValue({ updateLoader: jest.fn() }),
|
||||
formatDiagnostic: jest.fn(),
|
||||
@ -76,7 +76,7 @@ describe('Export', () => {
|
||||
exitMessageText: jest.fn(),
|
||||
};
|
||||
jest.mock(
|
||||
'../utils/data-transfer.js',
|
||||
'../../../utils/data-transfer.js',
|
||||
() => {
|
||||
return mockUtils;
|
||||
},
|
||||
@ -90,7 +90,7 @@ describe('Export', () => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
// Now that everything is mocked, load the 'export' command
|
||||
const exportAction = require('../actions/export/action');
|
||||
const exportAction = require('../action');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
@ -7,7 +7,7 @@ const {
|
||||
engine: { DEFAULT_SCHEMA_STRATEGY, DEFAULT_VERSION_STRATEGY },
|
||||
} = require('@strapi/data-transfer');
|
||||
|
||||
const { expectExit } = require('./utils/data-transfer.test.utils');
|
||||
const { expectExit } = require('../../../__tests__/commands.test.utils');
|
||||
|
||||
const createTransferEngine = jest.fn(() => {
|
||||
return {
|
||||
@ -62,7 +62,7 @@ describe('Import', () => {
|
||||
|
||||
jest.mock('@strapi/data-transfer', () => mockDataTransfer);
|
||||
|
||||
// mock utils
|
||||
// command utils
|
||||
const mockUtils = {
|
||||
loadersFactory: jest.fn().mockReturnValue({ updateLoader: jest.fn() }),
|
||||
formatDiagnostic: jest.fn(),
|
||||
@ -82,7 +82,7 @@ describe('Import', () => {
|
||||
exitMessageText: jest.fn(),
|
||||
};
|
||||
jest.mock(
|
||||
'../utils/data-transfer.js',
|
||||
'../../../utils/data-transfer.js',
|
||||
() => {
|
||||
return mockUtils;
|
||||
},
|
||||
@ -96,7 +96,7 @@ describe('Import', () => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
// Now that everything is mocked, load the 'import' command
|
||||
const importAction = require('../actions/import/action');
|
||||
const importAction = require('../action');
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
@ -11,7 +11,7 @@ const { resolve, join } = require('path');
|
||||
const fse = require('fs-extra');
|
||||
const inquirer = require('inquirer');
|
||||
|
||||
const exportTemplate = require('../actions/templates/generate/action');
|
||||
const exportTemplate = require('../action');
|
||||
|
||||
describe('templates:generate command', () => {
|
||||
beforeEach(() => {
|
@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { expectExit } = require('./utils/data-transfer.test.utils');
|
||||
const { expectExit } = require('../../../__tests__/commands.test.utils');
|
||||
|
||||
describe('Transfer', () => {
|
||||
// mock utils
|
||||
// command utils
|
||||
const mockUtils = {
|
||||
loadersFactory: jest.fn().mockReturnValue({ updateLoader: jest.fn() }),
|
||||
formatDiagnostic: jest.fn(),
|
||||
@ -25,7 +25,7 @@ describe('Transfer', () => {
|
||||
exitMessageText: jest.fn(),
|
||||
};
|
||||
jest.mock(
|
||||
'../utils/data-transfer.js',
|
||||
'../../../utils/data-transfer.js',
|
||||
() => {
|
||||
return mockUtils;
|
||||
},
|
||||
@ -72,7 +72,7 @@ describe('Transfer', () => {
|
||||
|
||||
jest.mock('@strapi/data-transfer', () => mockDataTransfer);
|
||||
|
||||
const transferAction = require('../actions/transfer/action');
|
||||
const transferAction = require('../action');
|
||||
|
||||
// console spies
|
||||
jest.spyOn(console, 'log').mockImplementation(() => {});
|
Loading…
x
Reference in New Issue
Block a user