Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Readme | Getting started #2

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Zsar
Copy link

@Zsar Zsar commented Jul 5, 2022

At this point I am still failing with

 FAIL  src/services/jest-same-file-tests.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at onResult (node_modules/@jest/core/build/TestScheduler.js:175:18)
      at node_modules/@jest/core/build/TestScheduler.js:316:17
      at node_modules/emittery/index.js:260:13
          at Array.map (<anonymous>)
      at Emittery.emit (node_modules/emittery/index.js:258:23)

Either I did something wrong or there are further steps necessary.

(Here is a commit I created as-is when I got stuck. It contains both the jest-same-file-tests.ts and a cache-service.ts where I had initially hoped I could just "plug & play".)

The file I am trying to test:

import {tests} from "jest-same-file-tests";

class ToBeTested {
    doSomething(): string {
        return "something"
    }
}

tests("ToBeTested", () => {
    it("doSomething returns something", () => {
        const thingy = new ToBeTested()
        expect(thingy.doSomething()).toBeTruthy()
    })
})

(Import was auto-completed by IDE. Tried to instead explicitly call global.tests without change.)

The invocation I am trying to test it with:

npm test -- jest-same-file-tests

resolves #1

@@ -23,7 +23,16 @@ const tests = require('jest-same-file-tests').tests
global.tests = tests
```

> TypeScript suport for injected global is in the TODO
Adjust either [testMatch](https://jestjs.io/docs/configuration#testmatch-arraystring) or [testRegex](https://jestjs.io/docs/configuration#testregex-string--arraystring) to include regular source files:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those will by default filter by __test__ and thence never find a same-file test.

Invoke your test e.g. using npm: `npm test -- <file name w.o. extension>`
** FIXME : still fails with "Your test suite must contain at least one test." - there must be steps missing or wrong! **

> TypeScript support for injected global is in the TODO
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing sup[p]ort here.

@Zsar Zsar changed the title Update readme getting started Update Readme | Getting started Jul 5, 2022
@Zsar Zsar force-pushed the update-readme-gettingStarted branch from 397de67 to 01a40de Compare July 5, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage documentation incomplete
1 participant