Skip to content

Commit

Permalink
fix(*): Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna-acondy committed Dec 27, 2020
1 parent 2baa6e8 commit 4233d26
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 2 additions & 4 deletions jest.config.js
Expand Up @@ -142,12 +142,10 @@ module.exports = {
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: ['**/*spec.[j|t]s?(x)'],
testMatch: ['./src/**/*spec.[j|t]s?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
testPathIgnorePatterns: ['/node_modules/', '/build'],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down
6 changes: 2 additions & 4 deletions jest.server.config.js
Expand Up @@ -2,7 +2,7 @@
// https://jestjs.io/docs/en/configuration.html

module.exports = {
testTimeout: 120000,
testTimeout: 240000,
// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down Expand Up @@ -145,9 +145,7 @@ module.exports = {
testMatch: ['**/*spec.server.[j|t]s?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],
testPathIgnorePatterns: ['/node_modules/', '/build'],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down
8 changes: 7 additions & 1 deletion src/cli.ts
Expand Up @@ -51,6 +51,8 @@ export async function cli(args: string[]) {
return
}
break
default:
process.projectDir = process.cwd()
}

switch (parsedCommand.name) {
Expand Down Expand Up @@ -142,7 +144,11 @@ function handleInvalidCommand() {

export async function checkAndSetProjectDirectory() {
const projectDir = process.projectDir
if (!projectDir || projectDir.trim() === 'null') {
if (
!projectDir ||
projectDir.trim() === 'null' ||
projectDir.trim() === 'undefined'
) {
process.projectDir = process.cwd()
}
const buildSourceFolder = path.join(process.projectDir, 'sasjs')
Expand Down
8 changes: 4 additions & 4 deletions src/utils/utils.spec.js → src/utils/utils.spec.ts
Expand Up @@ -6,19 +6,19 @@ import {

describe('utils', () => {
describe('generateTimestamp', () => {
let realDate
let realDate: DateConstructor
beforeAll(() => {
const currentDate = new Date('2020-10-02T10:10:10.10Z')
realDate = Date
global.Date = class extends Date {
constructor(date) {
global.Date = class extends DateConstructor {
constructor(date: string) {
if (date) {
return super(date)
}

return currentDate
}
}
} as DateConstructor
})

test('should generate a timestamp in the correct format', () => {
Expand Down

0 comments on commit 4233d26

Please sign in to comment.