Question: I have an script to looping over directories and match files with specific type. Unfortunately jest passes this test before it ends. I know why, but I don't know how to make script to wait for the end of looping. 

```
import fs from 'fs'
const path = require('path');

describe('something', () => {
    it('should something', () => {
        const traverseDir = (dir, callback) => {
            fs.readdirSync(dir).forEach(file => {
                let fullPath = path.join(dir, file);
                if (fs.lstatSync(fullPath).isDirectory()) {
                    callback(fullPath)
                    traverseDir(fullPath, callback);
                } else {
                    callback(fullPath)
                }
            });
        }

        traverseDir('src/', (fullPath) => {
            const splitted = fullPath.split('/')
            const filename = splitted[splitted.length - 1]
            if (filename.match(/.*.foo/)) {
                fs.readFile(fullPath, 'utf8', (err, data) => {
                    expect(err).toBe(null)
                    // some assertion
                })
            }
        })
    })
})

```

Answer: 
As mentioned in the comments you are likely needing to manage row/column weights.

Here is an example that does that while also showing how you can reduce your code by dynamically generating labels and entry fields instead of writing a wall of text for all of them.

```
import tkinter as tk

root = tk.Tk()
root.geometry('800x500')
root.title("TEST PLATFORM")
label_list = ['Cliente:', 'Responsavel por Teste:', 'Nome do Sistema:', 'Ref:', 'Data Base:', 'Data Teste:']
entry_list = []

# Row and Column configure to manage weights
root.columnconfigure(0, weight=1)
root.columnconfigure(2, weight=1)
root.rowconfigure(0, weight=1)
root.rowconfigure(2, weight=1)

# Add a frame to hold the rest of the widgets and place that frame in the row/column without a weight.
# This will allow us to center everything that we place in the frame.
frame = tk.Frame(root)
frame.grid(row=1, column=1)

# use a loop to create our widgets.
for ndex, label in enumerate(label_list):
    tk.Label(frame, text=label, font='10').grid(row=ndex, column=0, sticky='w')
    # Store the entry widgets in a list for later use
    entry_list.append(tk.Entry(frame, borderwidth=2, width=30))
    entry_list[-1].grid(row=ndex, column=1)

# Get and print each entry value.
def print_entries():
    for entry in entry_list:
        print(entry.get())

tk.Button(frame, text='Selecionar Arquivo', command=print_entries).grid(row=len(label_list)+1, column=0, columnspan=2)
root.mainloop()

```
If a column is empty (no widget inside), then it will not appear.

In the following example, I put a frame in column 0 with `width=100` in order to have my column 1 "centered". I also have the parameter `weight=1` for the 3 columns, so it grows the same way when I expand the window.

```
import tkinter as tk

root = tk.Tk()
for i in range(3):
    root.columnconfigure(i, weight=1)

tk.Frame(root, width=100).grid(row=0, column=0, sticky='w')
# tk.Label(root, text='Left').grid(row=0, column=0, sticky='w')
tk.Label(root, text='Center').grid(row=0, column=1)
tk.Label(root, text='Right').grid(row=0, column=2, sticky='e')

root.mainloop()

```