DEV Community

Discussion on: March 3rd, 2022: What did you learn this week?

Collapse
 
ktxxt profile image
Darko Riđić

Jan, you can chat with me if you still feel stuck with npm and cypress?

Collapse
 
janmpeterka profile image
Jan Peterka

Thanks for your kind offer!

Yeah, I'm still sort of stuck, on multiple levels. Basically, I'm unsure how the whole testing should be build around my app. More specifically:

1) I have unit tests in pytest, which uses some fixtures to set right database.
How do I somewhat integrate these two testing environments? Or how do I even think about them?

1b) Whats best practice -> recreating database data before every test?

2) It seems like I need to package.json on root of my app. however, in flask apps, I need to have normal js packages in /static folder to be usable (as i'm not using webpacker or something like that). so, i need to have two separate nmp projects inside my app? or I'm missing something?

3) I tried some way to create testing environment in Github Action, but I'm running into problems with pipenv/flask not working with correct env variables (thus not creating database). but thats sort of different issue.

Thanks for any pointers :)

Thread Thread
 
ktxxt profile image
Darko Riđić

2) If you want to keep inside one repository, you can create a directory just for Cypress inside. Inside that directory you can have a package.json and act like its a separate repo(or actually separate it to another repo).
Here is my cypress-template project with already split environments(dev, staging, prod)

You can definitely setup Github actions for any above mentioned structure.

1) When a commit occurs I would run(on both production and test/staging):

  • Lint
  • Unit tests
  • App build
  • e2e(cypress) test

Additionally, I would set up the project to Lint and unit test locally on every change before even commiting/pushing.

1b) Sure.

Thread Thread
 
ktxxt profile image
Darko Riđić

3) I do not have any experience with Github Actions, sorry :/

Thread Thread
 
janmpeterka profile image
Jan Peterka

I managed to make it working for now. It's for sure not the greatest, but I will hopefully improve it later, with more tests and so.

Thank you for your help and support!